有没有办法在nginxredirect从domain1.com到domain2.com的一切,除了首页?
现在我有:
server { listen 80; server_name www.domain1.com domain1.com; rewrite ^ http://domain2.com$uri permanent; }
这工作,除了我想要http://domain1.com (没有任何额外的path)独自留下,而不是redirect。 基本上,我需要redirect的一切,以避免断开的链接,但我想使用domain1的主页提供一个静态文件。
这应该做的伎俩。
server { listen 80; server_name www.domain1.com domain1.com; location = / { index static.file; # CHANGE THIS root /path/to/root/; # CHANGE THIS } location / { rewrite ^ http://domain2.com$uri permanent; } }