如何在nginx中重定向单个URL? [英] How to redirect single url in nginx?

查看:104
本文介绍了如何在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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆