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
子目錄跳轉:
重寫