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
rewrite ^/(news|product)/(.*)$ /old/$1/$2 permanent last;
放server块里。随手写的,没测试。
server {
server_name www.xxx.com xxx.com;
if ($host != 'www.xxx.com' ) {
rewrite ^/(.*)$ http://www.xxx.com/$1 permanent;
}
}
关键在 permanent
子目录跳转:
location ~* ^/news/ {
rewrite ^/news/(.*)$ http://www.xxx.com/old/news/$1 permanent;
}
rewrite