Nginx. 原来的URL:http://www.域名.com/news/aaa.htmlhttp://www.域名.com/product/aaa/bbb/xxx.html 需要把 /news/和/product/这2个目录下的网页重定向到以下URL:http://www.域名.com/old/news/aaa.htmlhttp://www.域名.com/old/product/aaa/bbb/xxx.html
rewrite ^/(news|product)/(.*)$ /old// permanent last;
放server块里。随手写的,没测试。
server { server_name www.xxx.com xxx.com; if ($host != 'www.xxx.com' ) { rewrite ^/(.*)$ http://www.xxx.com/ permanent; } }
关键在 permanent
permanent
子目录跳转:
location ~* ^/news/ { rewrite ^/news/(.*)$ http://www.xxx.com/old/news/ permanent; }
重写
放server块里。随手写的,没测试。
关键在
permanent
子目录跳转:
重写