0
我在我的Apache Web服务器中设置了虚拟主机,并且已经制定了一些规则,只需执行从一个URL到另一个URL的简单301重定向。不过,我现在已经有人问我能不能写一个重定向到另一个页面,同时保持URL相同的规则,我已经试过这样:如何在不更改URL的情况下重定向网页(使用Apache VirtualHost)
<VirtualHost *:80>
ServerName ZZZ.com
ServerAlias YYY.com ZZZ.com
Redirect/YYY.com
</VirtualHost>
这:
<VirtualHost *:80>
ServerName ZZZ.com
RewriteEngine on
RewriteRule ^/(.*) YYY.com/$1 [R]
</VirtualHost>
无论是做了我对他们的期望。他们看起来不对我,但我没有在任何地方找到有用的信息。我看过http://httpd.apache.org/docs/2.4/vhosts/examples.html和http://httpd.apache.org/docs/current/mod/mod_rewrite.html - 他们都不是很有帮助。
不幸的是,这只是让我的网页无限循环。无论如何感谢您的答案! :) –
试试我上面的编辑。由于YYY.com是主域,所以在ServerName指令中更好 – Gerben