本文介绍了如何在 Nginx 中重定向单个 URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在重新组织 URL 结构.我需要为特定 URL 设置重定向规则 - 我使用的是 Nginx.
I'm in the process of reorganizing URL structure.I need to setup redirect rules for specific URLs - I'm using Nginx.
基本上是这样的:
http://example.com/issue1 --> http://example.com/shop/issues/custom_issue_name1
http://example.com/issue2 --> http://example.com/shop/issues/custom_issue_name2
http://example.com/issue3 --> http://example.com/shop/issues/custom_issue_name3
谢谢!
推荐答案
把它放在你的服务器指令中:
Put this in your server directive:
location /issue {
rewrite ^/issue(.*) http://$server_name/shop/issues/custom_issue_name$1 permanent;
}
或复制它:
location /issue1 {
rewrite ^/.* http://$server_name/shop/issues/custom_issue_name1 permanent;
}
location /issue2 {
rewrite ^.* http://$server_name/shop/issues/custom_issue_name2 permanent;
}
...
这篇关于如何在 Nginx 中重定向单个 URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!