[英]Redirecting part of URL in Nginx
Trying to move my blog to a new site and I want to redirect some urls. 尝试将我的博客移至新站点,我想重定向一些URL。 I use nginx.
我用nginx。
https://blogurl.com/news/2014-08-19/post-3451/mt-preview-33e2742af1eb.php
The /news/2014-08-19/post-3451/mt-preview-33e2742af1eb.php
part would be always moving. /news/2014-08-19/post-3451/mt-preview-33e2742af1eb.php
部分将一直在移动。
Redirect to below: 重定向到下面:
https://blogurl.com/content/news/2014-08-19/post-3451/mt-preview-33e2742af1eb.php
I basically want to insert /content/
after https://blogurl.com
and so far I have 我基本上想在
https://blogurl.com
之后插入/content/
,到目前为止,我已经
rewrite ^(.*)$ /content/ break;
But my issue is my CMS sits on the same directory level 但是我的问题是我的CMS位于同一目录级别
https://blogurl.com/mt/admin
and if I simply apply the rewrite above my CMS address would move too. 如果我仅在CMS地址上方应用重写,它也会移动。 How could I prevent this.
我该如何预防。
Change your rewrite rule to: 将您的重写规则更改为:
rewrite ^(?!\\/mt)(.*)$ /content$1 break;
That should add /content
to all URLs that do not start with mt
这应该将
/content
添加到所有不以mt
开头的URL
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.