我想将www.example.itredirect到www.example.com/index-it.php
该网站只是一个一页的网站。
我希望这样做是透明的,因为www.example.it在redirect之后仍然会显示在地址栏上。
我已经尝试过,但它会生成一个内部服务器错误。
<VirtualHost *:80> ServerName www.example.it RewriteEngine on RewriteRule ^/.*$ http://www..com/index-it.php [P,L] </VirtualHost>
这可能会起作用, 但它不提供透明的redirect:
<VirtualHost *:80> ServerName www.example.it RewriteEngine on #RewriteRule ^/.*$ http://www.example.com/index-it.php [P,L] Redirect 301 / http://www.example.com/index-it.php </VirtualHost>
有什么想法吗? 谢谢。
我build议你实际上不要redirect,因为“redirect”实际上的意思是“告诉浏览器请求这个其他页面”。
另外,我打赌你并不是真的想redirect所有的请求,因为如果你的浏览器URL栏显示www.example.it并且它已经加载的页面有一个对/logo.png的引用,浏览器将请求http://www.example.it/logo.png ,得到www.example.com/index-it.php的输出结果会很惊讶。
因为你正在使用[P]标志,所以你实际采取的方法是将www.example.it所有请求反向附加到www.example.com ,在代理之前,在www.example.it内部重写一些索引请求子集www.example.it到/index-it.php 。 当不使用重写页面列出“代理”作为其时间之一不使用mod_rewrite 。 mod_proxy本身可以帮助你的代理; mod_rewrite的文档实际上build议在P标志上使用mod_proxy指令。
请阅读mod_proxy关于在打开服务器之前确保服务器安全的警告。 索引文件的杂耍可能是mod_rewrite的合理使用,但不需要使用P标志。
只是一个愚蠢的问题:mod_proxy没有启用