nginx 将旧 URL 重定向到新 URL
nginx redirect old URL to new URL
我们刚刚将所有产品 url 更新为新产品 url。它只是在 URL 中添加了一些字母。
一个例子
旧 URL:
http://www.example.com/parent/children/product.html
新 URL:
http://www.example.com/new-parent/children/product.html
(刚刚在 "parent" 中添加了 "new-")
我试过这个但是不行。
location /parent {
rewrite ^/parent(.*) http://$server_name/new-parent permanent;
}
所以有人可以帮我更正这个重定向吗?
尝试将 rewrite ^/parent(.*) http://$server_name/new-parent permanent;
放入 server
指令,而不是 /parent
位置。
我们刚刚将所有产品 url 更新为新产品 url。它只是在 URL 中添加了一些字母。 一个例子
旧 URL:
http://www.example.com/parent/children/product.html
新 URL:
http://www.example.com/new-parent/children/product.html
(刚刚在 "parent" 中添加了 "new-")
我试过这个但是不行。
location /parent {
rewrite ^/parent(.*) http://$server_name/new-parent permanent;
}
所以有人可以帮我更正这个重定向吗?
尝试将 rewrite ^/parent(.*) http://$server_name/new-parent permanent;
放入 server
指令,而不是 /parent
位置。