Nginx pseudo-static configuration and common Rewrite pseudo-static rules, nginxrewrite
Pseudo-static is a way to change the file suffix to any possible one. If I want to convert the PHP file pseudo-static to an html file, this is quite simple, the following describes the nginx pseudo-static configuration method. For mo
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
Parse CI: the rewrite rules of the CodeIgniter framework under Nginx. I recently studied the CI framework and found that the routing function of this framework is faulty under Nginx and reported a 404 error. later I checked the information online and found that PATH_INFO needs to be enabled. After nginx7.16, it seems t
This article mainly introduces Laravel's nginx rewrite rule instance code, the need for friends can refer to the following
Laravel Basic Rewrite rules
Location/{ index index.html index.htm index.php; Try_files $uri $uri//index.php? $query _string; }
Remove the trailing slash, SEO more friendly
if (!-d $request
#访问 $uri # if exists $uri, visit him # If $uri are not end Of/and exists/vhosts/$http _host/$uri, visit him # if $uri is end of /And exists/cache/$http _host/$uri-/index.php #结束 (by [email protected]-please contact us if you have any errors) serve R{ Listen; server_namegame1.wap.loc game2.wap.loc game3.wap.loc wap.loc www.wap.loc; Location/ { RootD:/dev_wap; Indexindex.html index.htm index.php; Try_files$uri/vhosts/$http _host/$uri/cache/$http _host/$uri/index.html @
: This article describes examples of writing nginx pseudo-static rewrite rules. For more information about PHP tutorials, see. In the website configuration file www. huobo. cc. conf
.....
Server_name www. huobo. cc;Index index.html index.htm index. php;Root/home/wwwroot/huobo;......Add it under the root lineIncludeHuobo. cc. conf;
Content:
Location /{
nginx configuration Shopex pseudo-static is actually the simplest. Add a rule to determine if there is a file or directory (!-E), and then forward it to the root directory under the index.php for processing.Location /{if (!-e $request _filename) {rewrite ^/(. +\.html|xml|json|htm|php|jsp|asp|shtml)) $/index.php?$1 last; }}If the Shopex is placed in a different directory, simply change the "/" to a relative
I recently studied the CI framework and found that the routing function of this framework is faulty under Nginx. I reported a 404 error. Later I checked the information on the Internet,You need to enable PATH_INFO. After nginx7.16, it seems that PATH_INFO is supported. You only need to enable it in the configuration file.Open the nginx. conf file and add rewrite
1. It should be noted that all the rewrites that have been circulating on the Internet are incorrect. In the following rewrite, the semicolon contains an extra Transfer Character "\", which is required in Apache, but not in nginx. Rewrite ^/thread-([0-9] +)-([0-9] +)-([0-9] +) \. html $/viewthread. php? Tid = $1 extra = Page \ % 3d $3 page = $2 last; correct sh
So, I want to implement a url:example.com/test.php/a/b/c, the Web directory has a test.php file, want to receive/a/b/c as routing parameters to implement the routing function.
If you do not set the Rewite rule, it is possible to open example.com/test.php, but open example.com/test.php/a/b/c will report 404. And then I just want to rewrite the rules myself.
After trying a lot of times, I found
location /tes
Www.huobo.cc.conf in the Web site configuration file
.....
server_name www.huobo.cc;Index index.html index.htm index.php;Root/home/wwwroot/huobo;......Add the include huobo.cc.conf below the root line;
The contents are:
Location/{Rewrite ^/[a-za-z]+/([0-9]+)/vod\-([0-9]+)-([0-9]+] \.html$/video/index.php?$1-$2-$3.html last;}
The rule is to rewrite the http://www.huobo.cc/xiju/13239/vod-0-0.html to ind
The rewrite rule in nginx has more than 10 $10 parameters.
PHP file P. PHP code content:
For example, get the http://www.jms.com/wk/jack-tom-4-5-6-7-8-9-jack.html 10th-bit parameter "Jack" is the value of name. How can I get the value Jack.
Under Apache:
In nginx, rewrite can be written:
Are you worrying about your website being swept away all the time? Is my website helpless without an enterprise-level firewall? If you are using nginx, congratulations. The nginx configuration file is a script program that can help you filter all the submitted content you want to filter. I have summarized some anti-injection scanning rules for
Nginx-rewrite regular expression matching
Case matching
~ to match case sensitivity~* for case-insensitive matching!~ and!~* are case insensitive and case-insensitive mismatches, respectively.
File and directory matching
-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 us
Why do I need to use rewrite rules
----The life of the site is constantly updated and maintained, according to the needs of the business development of the transfer server maintenance, the organization of the directory structure, change the URL or even changed to the new domain name and so on often happen. In order for the customer to not be affected by this, the best approach is to use the Apache
IntroducedPeople often encounter such demand, an active page URL address is very long, promote product operation and user feedback is not easy to rememberNot beautiful, but temporarily no way to modify the code, this time can be used to rewrite. Or you now have a website upgrade to HTTPS now some users are still accessing HTTP you want to unify HTTPS, which can be implemented with rewrite rules.Rewrite over
.
Copy Code code as follows:
Rewritecond%{http_referer}!^$
Rewritecond%{http_referer}!^http://(www\.)? jb51\.net/[NC]
Rewriterule \. (gif|jpg|png) $–[f]
If the {http_referer} value is not empty, or if it is not from your own domain name, this rule uses [F]flag to block URLs ending with gif|jpg|png
If you are adamant about this hotlinking, you can also change the image so that users visiting the Hotlinking site know that the site is stealing your pictures.
Copy Code c
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.