Nginx.
原來的URL:
http://www.網域.com/news/aaa.html
http://www.網域.com/product/aaa/bbb/xxx.html
#
需要把/news/和/product/這2個目錄下的網頁重定向到以下URL:
http://www.域名.com/old/news/aaa.html
http://www.網域.com/old/product/aaa/bbb/xxx.html
大家讲道理2017-05-16 17:24:58
rewrite ^/(news|product)/(.*)$ /old// permanent last;
放server塊裡。隨手寫的,沒測試。
天蓬老师2017-05-16 17:24:58
server {
server_name www.xxx.com xxx.com;
if ($host != 'www.xxx.com' ) {
rewrite ^/(.*)$ http://www.xxx.com/ permanent;
}
}
關鍵在 permanent
子目錄跳轉:
location ~* ^/news/ {
rewrite ^/news/(.*)$ http://www.xxx.com/old/news/ permanent;
}