【问题标题】:nginx redirect old URL to new URLnginx 将旧 URL 重定向到新 URL
【发布时间】:2015-02-14 02:09:37
【问题描述】:

我们刚刚将所有产品网址更新为新网址。它只在 URL 中添加一些字母。 一个例子

旧网址:

http://www.example.com/parent/children/product.html

新网址:

http://www.example.com/new-parent/children/product.html

(只是在“父”中添加了“new-”)

我尝试了这个但不起作用。

location /parent {
    rewrite ^/parent(.*) http://$server_name/new-parent$1 permanent;
}

那么任何人都可以帮助我更正此重定向吗?

【问题讨论】:

  • “不工作”是对问题的错误描述。你应该描述发生了什么。同时显示完整的服务器配置
  • 嗨,阿列克谢。我的意思是旧网址没有重定向到新网址,谢谢
  • “show full config”哪个字不清楚?

标签: redirect nginx rewrite url-redirection


【解决方案1】:

尝试将rewrite ^/parent(.*) http://$server_name/new-parent$1 permanent; 放入server 指令中,而不是放入/parent 位置。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-15
    • 2015-09-14
    • 1970-01-01
    • 2017-06-19
    • 2014-04-10
    • 2021-12-27
    相关资源
    最近更新 更多