开发者

nginx - redirect a certain path to another domain

开发者 https://www.devze.com 2023-01-03 05:33 出处:网络
I am very unfamiliar with nginx, as a forewarning, and also can\'t find any actual references on the regex system they use. So right now it\'s a black box to me.

I am very unfamiliar with nginx, as a forewarning, and also can't find any actual references on the regex system they use. So right now it's a black box to me.

All I want to do is redirect a user trying to go to www.mydomain.com/mydirectory/X to www.myotherdomain.com/X .

Seems like I should be using the rewrite command but the syntax of the regex is eluding me开发者_如何学C.

Thanks in advance.


I made a solution that works. I had it before posting this question but didn't realize I needed to restart nginx. Put the following inside your server block.

rewrite ^(/mydirectory/)(.*)$ http://www.myotherdomain.com/$2 permanent;
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号