一、访问正常,现在需要访问abc.com,直接跳转到。
点击(此处)折叠或打开
- server {
- listen 80;
- server_name abc.com;
- access_log off;
- rewrite (.+) $scheme:// permanent;
- }
首先需要在你的server_name里面把和都写上。
然后做如下配置:
点击(此处)折叠或打开
- location / {
- if ($host = '')
- {
- rewrite ^/(.*)$ /$1 permanent;
- }
- }
点击(此处)折叠或打开
- set $rewrite true;
- if ($remote_addr = "xxx.xxx.xxx.xxx") {
- set $rewrite false;
- }
- if ($rewrite = true) {
- rewrite (.+) /maintenance.html;
- }
- location = /maintenance.html {
- root /var/vhost;
-
}
比如:/post/addpost/913.shtml跳转到/bbs/post/addpost/913.shtml
点击(此处)折叠或打开
- location /post {
- rewrite (.+) /bbs$1 permanent;
- }
点击(此处)折叠或打开
- if ($request_uri ~* ^/note\.php\?product_code=(.*)$) {
- rewrite (.*) permanent;
- }
点击(此处)折叠或打开
- if ($request_uri ~ ^/forum-(140|141|142|143|144|145|150|151|152|153|154|155|156|157|158|159|200|222|223|224|225|226|227|228)-(\d+).html$) {
- rewrite (.*) /list permanent;
- }
点击(此处)折叠或打开
- location ~* /upload/.*\.php$ {
- return 404;
- }
点击(此处)折叠或打开
- location ~* ^/ab/maintain/main.html {
- rewrite (.+) /maintain/main.html permanent;
- }