Nginx set指令

nginx set指令

[root@localhost conf.d]# vim /etc/nginx/conf.d/rewrite.conf
server {
        listen 80;
        server_name www.rewrite.com rewrite.com;
        access_log /var/log/nginx/test2-access.log main;
        error_log /var/log/nginx/test2-error.log;
        location /{
                root /html/rewrite;
                index index.html index.htm index.php;
                if ($host ~* "^www.rewrite.com$|^rewrite.com$" ) {
                        break;
                }
                if ($host ~* "^(.*)\.rewrite\.com$" ) {
                        set $user $1;
                        rewrite .* http://www.rewrite.com/$user permanent;
                }
        }

        location /one{
                root /html/rewrite;
                index index.html index.htm index.php;
        }
        location /two{
                root /html/rewrite;
                index index.html index.htm index.php;
        }
        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
        root /var/www/test;
        }
}

[root@localhost conf.d]# tree /html
/html
└── rewrite
    ├── index.html
    ├── one
    │   └── index.html
    └── two
        └── index.html

上一篇:vue 2.0 配置路由解决跨域问题


下一篇:could not be translated. Either rewrite the query in a form that can be translated, or switch to cli