1. Introduction to rewrite rulesThe main function of Rewirte is to implement a URL jump, and its regular expression is based on the Perl language. Can be based on both server-level (httpd.conf) and directory-level (. htaccess) methods. If you want to use the rewrite module, you must first install or load the rewrite module. There are two ways to compile Apache wh
Regular Expression matching, where:
*~ Case-sensitive matching
*~ * Case-insensitive match
*!~ And !~ * Case-insensitive and case-insensitive
File and directory match, where:
*-F and! -F is used to determine whether a file exists.
*-D and! -D is used to determine whether a directory exists.
*-E and! -E is used to determine whether a file or directory exists.
*-X and! -X is used to determine whether a file is executable.
Flag labels include:
* Last is equivalent to the [L] Mark in Ap
Use the following code to jump to the specified server {code ...} now, if you want to get the IP address of the nginx server on the server to which you want to jump, the commonly used code for getting the nginx server does not seem to be available. Is there a way to get the IP address? Amp; lt ;? Php $ ip $ _ SERVER [ quot; REMOTE _... use the following code to jump to the specified SERVER.
Label:Syntax format for rewrite:
Rewriteengine on #要想rewrite起作用, it has to be written.
Rewritebase Url-path #设定基准目录, for example, if you want to rewrtie a file under the root directory, is "/"
Rewritecond test-string Condpattern #写在RewriteRule之前, can have one or n, used to test the matching conditions of the rewrite, specifically how to write, t
, ^ (. *) $ means all content. Then the space is followed by the directory where we guide the user, and we take him to the new domain. Refers to what is obtained from the matching URL in the preceding brackets.
This is a complete and small example. about how to call a part of the URL in Rewritecond, we can refer to this article (Apache mod_rewrite Learning (Rewritecond rewrite rules), 3, now learn to use, l
In order to facilitate the search engine crawl (in other words is false static), the following is the rules of the URL rewrite, the effect of looking at my Chinadigger link address. My current rewrite rule:
Copy Code code as follows:
[Isapi_rewrite]
# 3600 = 1 hour
Cacheclockrate 3600
Repeatlimit 32
# Protect Httpd.ini and Httpd.parse.errors
-Unmodified-Since:Max-Forwards:Proxy-Authorization:Range:Referer:User-Agent:Any-Custom-HeaderFor more information about HTTP header files and their values, see RFC2068.
ServerVariable returns the value of the server variable defined by this parameter. For example, for the server port, the list of all server variables should be established in the IIS documentation, and the variable name should be prefixed with the % character;CondPatternThe regular expression to match TestVerbRule expression matc
Remove the index.php from the URLThinkphp as a PHP framework, is a single entry, then its original URL is not so friendly. But thinkphp provides a variety of mechanisms to customize the desired URL format, in conjunction with Apache. htaccess files, it is possible to customize a more user-friendly SEO URL address.The. htaccess file is a configuration file in the Apache server that is responsible for the Web page configuration under the relevant directory. We can use the
There are two methods for server-level (httpd.conf), one is to use rewriteengine on to open the rewrite function under the global httpd.conf, and the other is to use Rewriteengine in the local area. On to turn on the rewrite feature, the following will illustrate the need to note that the rewrite feature must be turned on with Rewriteengine on in each virtualhost
Regular Expression matching, where:
*~ Case-sensitive matching*~ * Case-insensitive match*!~ And !~ * Case-insensitive and case-insensitiveFile and directory match, where:
*-F and! -F is used to determine whether a file exists.*-D and! -D is used to determine whether a directory exists.*-E and! -E is used to determine whether a file or directory exists.*-X and! -X is used to determine whether a file is executable.Flag labels include:
* last is equivalent to the [l] Mark in Apache, indica
ISAPIRewrite is the most widely used rewrite component in IIS. With this component, You can implement the mod_rewrite function in Apache. For Seo, is the basic equipment for 301 redirection in IIS.
Currently, most of the versions on the Internet are older than version 1.3. We recommend that you use the latest ISAPI rewrite 3 with better functions and more flexible and rich
1. What is Nginx's rewrite rule?The main function of rewrite is to implement the rewrite of the URL, the nginx rewrite rule adopts pcre (PerlCompatible Regular Expressions) Perl-compatible regular expression syntax for rule matching, ifYou need
Problem title, use the following code to jump to the specified server
rewrite ^/(.*)$ http://xxxx.cn/index.php?id=/$1 permanent;
Now, want to jump to the server in getting this nginx server IP address, using PHP, commonly used to get the code seems to get not, ask whether there is a way to get to?
$ip = $_server["REMOTE_ADDR"];Echo $ip;?>
Reply content:
Proble
does not exist, if there is a normal response, if it does not exist then rewrite tryfiles to the new image404 location, directly return 404 status Code.Example 2:
1
Rewrite ^/images/(. *) _ (\d+) x (\d+) \. ( Png|jpg|gif) $/resizer/$. $4?width=$2height=? Last ;
The file request for the shape /images/bla_500x400.jpg , rewritten to the /resizer/bla.jpg?width=500height=40
IISServer has been very few and almost out of the market. Nginx becomes the mainstream of the market.Back up a httpd.ini, all content such as the following:[isapi_rewrite]# 3600 = 1 hourcacheclockrate 3600RepeatLimit 32#rewritecond Host:!^job\.zbphp\.com$ #RewriteRule ^ (. *) $ http\://job\.zbphp\.com$1 [I,r]rewriterule ^/public/([a-z0-9]{32}) \.html$/detail\.php\?md5=$1rewriterule ^/so ([ a-z]+) _ ([^\/]+)/?$/search\.php\?rewritefn=$1$1=$2page=$3rewr
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.