需要帮助使用.htaccess实现重定向+域屏蔽。它正在部分工作。它适用于子页面和子目录,但不适用于域本身。
我有两个域名"redir1"answers"redir2"。目标是用.htaccess和类似的掩码实现重定向:
http://redir2 —> http://redir1
http://redir2/sub.php —> http://redir1/sub.php
http://redir2/index.php —> http://redir1/index.php
显示给访问者的url必须保留他们输入的内容:
http://redir2
http://redir2/sub.php
http://redir2/index.php
但如果他们输入了http://redir1
,他们应该会在url中看到http://redir1
。
每个域都有以下两个文件:index.php惠普
这是.htaccess:中的代码
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www'.)?redir2$ [NC]
RewriteRule ^ http://redir1%{REQUEST_URI} [L,NE,P]
它对所有在域(子页面和子目录)后有内容的请求都能很好地工作。例如:
http://redir2/sub.php
http://redir2/index.php
但如果我只输入http://redir2/
,我会得到一个"未找到"错误:
The requested URL /index.html was not found on this server.
事实上,我没有index.html,但我有index.php如何在不添加index.html的情况下解决问题?
感谢
可能使用DirectoryIndex index.php
?