Nginx301重定向该怎么写
滿天的星座
滿天的星座 2017-05-16 17:22:58
0
3
621

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

滿天的星座
滿天的星座

全部回复(3)
大家讲道理
rewrite ^/(news|product)/(.*)$ /old// permanent last;

放server块里。随手写的,没测试。

Peter_Zhu
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;
}
某草草

重写

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!