[英]Nginx url domain redirect
With nginx, I would like to configure a redirect between two domains like this: 使用nginx,我想在两个域之间配置重定向,如下所示:
domainA.com/<anypath>
to domainB.com/redirect/<anypath>
domainA.com/<anypath>
到domainB.com/redirect/<anypath>
My code right now: 我现在的代码:
server {
listen 80;
server_name .domainA.org(.*)$;
rewrite ^ http://domainB.org/redirect$1?;
}
The redirect from domainA to domainB works, but it doesn't include /redirect
in the new path. 从domainA到domainB的重定向有效,但是在新路径中不包含
/redirect
。 Any help is appreciated! 任何帮助表示赞赏! thanks!
谢谢!
Nginx has some built-in functionality to handle this for you. Nginx具有一些内置功能可以为您处理此问题。 Try this:
尝试这个:
server {
listen 80;
server_name domainA.org;
return 301 http://domainB.org/redirect$request_uri;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.