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 matchi
Rewrite is a server rewrite pulse technology that allows servers to support URL rewriting. It is a new and popular server technology. It can also restrict specific IP addresses to access websites. In many cases, access from an IP address can easily cause a CPU usage of 100% (for example, fixed crawling by some search engines and massive collection sites by others
Run centos6.5 + lanmpapache as the backend and nginx as the front-end software: wordpressnginx virtual host configuration: server?listen80=server_namexxx.com?rootvarwwwxxxhtml#indexindex.htmlindex.htm index. php ;...
Centos 6.5 + lanmp
Apache is used as the backend and nginx is used as the front-end
Software: wordpress
The nginx virtual host configuration is as
Trust that most of the Linux VPs partners are using this agile deployment nginx. This day, we will clear the most common PHP rewrite (pseudo static Law ).
WordPress:
Location /{Index index.html index. php;If (-F $ request_filename/index.html ){Rewrite (. *) $1/index.html break;}If (-F $ request_filename/index. php ){Rewri
Objective:There is a very important concept in Nginx, which is the rewrite rule. It modifies the URL and then makes internal redirects. Rewrite granted Nginx more freedom, making the post-service access more local.This article will briefly describe the
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.
: #直接匹配网站根, through the domain name to visit the site home more frequently, using this will speed up processing, the official website said. #这里是直接转发给后端应用服务器了 or a static home # first required rule location =/{Proxy_pass Http://tomcat:8080/index }# The second required rule is to handle a static file request, which is Nginx's strong point as an HTTP server # there are two configuration modes, a directory match or a suffix match, either one or a combination of the use Location ^~/static/{ ro
A Regular expression matches, where:
* ~ to Match case sensitivity* ~* matching for case-insensitive case*!~ and!~* are case insensitive and case-insensitive mismatches, respectively
Two File and directory matching, where:
*-F and!-f are used to determine whether a file exists*-D and!-d used to determine whether a directory exists*-E and!-e used to determine whether a file or directory exists*-X and!-x are used to determine whether a file is executable
Three The last parameter of the
Overview IIS URL Rewrite 2.1 Enables Web administrators to create powerful rules that make it easier for users to remember URLs and make search engines easier to find. Rewrite the mappings by using the rule template. NET provider and other features integrated into IIS Manager, Web administrators can easily set rules to define HTTP-based headers, HTTP response or
the following:// The name of this function is "Post", which means to do some aftercare for rewrite processing ngx_http_core_post_rewrite_phase {// in general, that is, R-> uri_changed> 0, r-> phase_handler is set to pH-> next, // and this pH-> next, which has been set to pH-> next = find_config_index when the phase initialization starts, // In the case of non-break or last, the subsequent phase is the so-called find config stage, but here it is/R-> p
following matching examples are set up/- config a exactly matches exactly, even if /index.html does not match /downloads/download.html -config B matches B, there is no match down , with B/images/1. gif--- configuration D matches to F, down to D, stop down/images/abc/def- config D longest match to G, down to D, stop down you can see that any /images/ beginning with the start will match to D and stop, FG write here is meaningless, H is never round, here just to illustrate the match order /docume
http://tomcat:8080/index}# the second required rule is to handle a static file request, This is nginx as the strength of the HTTP server # There are two configuration modes, directory matching or suffix matching, either one or use location ^~/static/{ root/webroot/static/;} Location ~* \. (Gif|jpg|jpeg|png|css|js|ico) $ { root/webroot/res/;} #第三个规则就是通用规则, used to forward a dynamic request to the backend Application Server # non-static file requ
file request, which is Nginx's strength as an HTTP server# There are two configuration modes, directory matching or suffix matching, either one or useLocation ^~/static/{root/webroot/static/;}location ~* \. (Gif|jpg|jpeg|png|css|js|ico) $ {root/webroot/res/;}#第三个规则就是通用规则, used to forward dynamic requests to backend application servers#非静态文件请求就默认是动态请求, according to the actual grasp#毕竟目前的一些框架的流行, with a. php,.jsp suffix is rare .Location/{Proxy_pass http://tomcat:8080/} http://tengine.taobao.org/
the parameters after the jump to remain consistent.
For example: http://bbs.abc.com/post/addpost/913.shtml jump to Http://www.abc.com/bbs/post/addpost/913.shtml
Location/post {
Rewrite (. +) http://www.abc.com/bbs$1 permanent;
}
V. URI-based jumps
if ($request _uri ~* ^/note\.php\?product_code= (. *) $) {
Rewrite (. *) http://www.abc.com permanent;
}
A Regular expression matching, where:* ~ For case-sensitive matching* ~* for case-insensitive matching*!~ and!~* are case insensitive and case insensitiveTwo File and directory matching, where:*-F and!-f to determine if a file exists*-D and!-d to determine if a directory exists*-E and!-e to determine if a file or directory exists*-X and!-x to determine if the file is executableThree The last parameter of the rewrite directive is the flag flag, and the
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.