In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you "what are the pseudo-static rules of rewrite in Apache", which is easy to understand and clear, hoping to help you solve your doubts, the following let the editor lead you to study and learn what are the pseudo-static rules of rewrite in Apache?
The main function of Rewirte is to realize the jump of URL, and its regular expression is based on Perl language. It can be based on server-level (httpd.conf) and directory-level (.htaccess). If you want to use the rewrite module, you must first install or load the rewrite module. There are two methods: one is to install the rewrite module directly when compiling apache, and the other is to install apache in DSO mode when compiling apache, and then install the rewrite module using source code and apxs
Based on the server (httpd.conf), there are two ways, one is to directly use RewriteEngine on to open the rewrite function under the global httpd.conf; the other is to use RewriteEngine on to turn on the rewrite function locally. The following examples will illustrate that you must use RewriteEngine on to turn on the rewrite function in each virtualhost. Otherwise, the rules in virtualhost will not take effect without RewriteEngine on.
Based on directory-level (.htaccess), it is important to note that the FollowSymLinks property of this directory must be turned on and RewriteEngine on must be declared in .htaccess.
Actual combat
The code is as follows:
RewriteEngine on
RewriteCond% {HTTP_USER_AGENT} ^ MSIE [NC,OR]
RewriteCond% {HTTP_USER_AGENT} ^ Opera [NC]
RewriteRule ^. *-[FMagol L] where "-" means there is no replacement, visitors whose browsers are IE and Opera will be banned.
Example:
The code is as follows:
RewriteEngine On
RewriteBase / test
RewriteCond% {REQUEST_FILENAME} .php-f
RewriteRule ([^ /] +) $/ test/$1.php
# for example: / test/admin = > / test/admin.php
RewriteRule ([^ /] +). Html$ / test/$1.php [L]
# for example: / test/admin.html = > / test/admin.php
Configure a multi-user virtual server using Apache's URL Rewrite
To achieve this function, you must first turn on the pan-domain name resolution of the domain name on the DNS server (do it yourself or find a domain name service provider to do it). For example, I parsed * .kiya.us and * .kiya.cn to my IP address 70.40.213.183.
Then, take a look at my Apache settings for virtual hosts for * .kiya.us.
The code is as follows:
ServerAdmin webmaster@kiya.us
DocumentRoot / home/www/111cn.net
ServerName dns.kiya.us
ServerAlias dns.kiya.us kiya.us * .kiya.us
CustomLog / var/log/httpd/osa/access_log.log "common
ErrorLog / var/log/httpd/osa/error_log.log "
AllowOverride None
Order deny,allow
# AddDefaultCharset GB2312
RewriteEngine on
RewriteCond% {HTTP_HOST} ^ [^.] + .kiya. (cn | us) $
RewriteRule ^ (. +)% {HTTP_HOST} $1 [C]
RewriteRule ^ ([^.] +) .kiya. (cn | us) (. *) $/ home/www/111cn.net/sylvan$3?un=$1&% {QUERY_STRING} [L]
In this setting, I set the Document Root of * .kiya.cn and * .kiya.us to / home/www/111cn.net
Restrict the directory to display only pictures
The code is as follows:
< IfModule mod_rewrite.c>RewriteEngine on
RewriteCond% {REQUEST_FILENAME}! ^. *. (gif | jpg | jpeg | png | swf) $
RewriteRule. * $- [FMAL]
< /IfModule>Description of RewriteRule regular expression:
. Match any single character
[chars] matching string: chars
[^ chars] mismatch string: chars
Text1 | text2 optional string: text1 or text2
? Match 0 to 1 character
* match 0 to multiple characters
+ match 1 to more characters
^ string start flag
$string end flag
N escape character flag
Reverse reference $N for matching variable calls in RewriteRule (0
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.