3.
Set the expiration time for favicon.ico and robots.txt; Here, favicon.ico is 99 days, robots.txt is 7 days, and no 404 error log is recorded
1.
location
~(favicon.ico) {
2.
Log_not_found off;
3.
expires
99d;
4.
break;
5.
}
6.
7.
Location ~(robots.txt) {
8.
Log_not_found off;
9.
expires
7d;
10.
break;
location
^~ /html/scripts/loadhead_1.js {2.
access_log off;
3.
root /opt/lampp/htdocs/web;
600;
5. break;
6.
}
File anti-hotlinking and set expiration timeThe return 412 here is a custom http status code, the default is 403, which is convenient for finding the correct hotlinking request"rewrite ^/ http://leech. c1gstudio.com/leech.gif;"Show an anti-hotlink picture"access_log off;"Do not record access logs, reduce stress
"expires 3d" Browser cache of all files for 3 days
1.
location
~* ^.+.(jpg|jpeg|gif|png|swf|rar|zip|css|js)$ {
2. valid_referers
none blocked *.c1gstudio.com *.c1gstudio.net localhost 208.97.167.194;
3. if
($invalid_referer) {
4.
rewrite ^/ http://leech.c1gstudio.com/leech.gif;5.
Return 412;
6.
break;
7.
access_log off;9.
root /opt/lampp/htdocs/web;10. expires 3d;
11.
Only fixed IP access is allowed website and add the password
1.
/opt/htdocs/www;2.
allow
208.97.167.194;3.
allow
222.33.1.2;
4.
allow
231.152.49.4;
5. deny
all;
6. auth_basic
"C1G_ADMIN";
7. auth_basic_user_file
htpasswd;
Convert files in multi-level directories into one file to enhance seo effect
/job-123-456-789.html points to /job/123/456/789.html
1. rewrite
^/job-([0-9]+)-([0-9]+)-([0-9]+).html$ /job/$1/$2/jobshow_$3.html last;
Point a folder in the root directory to the second-level directory
For example, /shanghaijob/ points to /area/shanghai/
If you change last to permanent, the browser address bar will show /location/shanghai/
1. rewrite
^/([0-9a-z]+)job/(.*)$ /area/$1/$2 last;
A problem with the above example is that it will not match when accessing /shanghai
1 . rewrite
^/([0-9a-z]+)job$ /area/$1/ last;
2. rewrite
^/([0-9a-z]+)job/(.*)$ /area/$1/$2 last;
In this way, /shanghai can also be accessed, but the relative link in the page cannot be used,
such as The real address of ./list_1.html is /area /shanghia/list_1.html and will become /list_1.html, making it inaccessible.
Then it won’t work if I add automatic jump
(-d $request_filename) It has a condition that it must be a real directory, but my rewrite is not, so it has no effect
1. if
(-d $request_filename){
2.rewrite
^/(.*)([^/])$ http://$host/$1$2/ permanent;
3. }
After knowing the reason, it will be easier to handle, let me Jump manually
1. rewrite
^/([0-9a-z]+)job$ /$1job/ permanent;
2.rewrite
^/([0-9a-z]+)job/(.*)$ /area/$1/$2 last;
Redirect when files and directories do not exist:
1. if
(!-e $request_filename) {
2. proxy_pass
http://127.0.0.1;
3. }
Domain name jump
1. server
2.
{
3.
listen 80;
4.
server_name jump.c1gstudio.com;
5.
index index.html index.htm index.php;
6.
root /opt/lampp/htdocs/www;
7.
rewrite ^/ http://www.c1gstudio.com/;
8.
access_log off;
9.
}
多域名转向
1. server_name
www.c1gstudio.com www.c1gstudio.net;
2.
index index.html index.htm index.php;
3.
root /opt/lampp/htdocs;
4. if
($host ~ "c1gstudio.net") {
5. rewrite
^(.*) http://www.c1gstudio.com$1 permanent;
6. }
三级域名跳转
1. if
($http_host ~* "^(.*).i.c1gstudio.com$") {
2. rewrite
^(.*) http://top.yingjiesheng.com$1;
3. break;
4. }
域名镜向
1. server
2.
{
3.
80;
through through out out out out out Out Out Out Out Out over into ’ over into ’s ’ s ’ through out out ’ s ’ ’ back ’ behalf ” ” “ server_name ” mirror.c1gstudio.com;
5. в
index index.html index.htm index.php;6.
Root /opt/lampP/htdocs/www ;
7.
.
access_log off;
9.
}
The above introduces the location configuration of nginx, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.