2个域名,htaccess将一个重定向到index.html而不是另一个域名

时间:2012-05-18 10:57:28

标签: .htaccess

我正在开发一个网站,其中有2个域指向同一个public_html文件夹。

默认情况下服务器服务器index.html。我的代码使用htaccess将所有调用路由到index.php,但我只希望现在的开发URL发生这种情况而不是实时URL。

我尝试将live.com和www.live.com路由到www.live/index.html - 但是我得到了一个重定向循环,因为我不知道如果index.html在URL中,它会如何使其中断。

有人可以帮忙吗?

我试过了:

# Disable live domain
RewriteCond %{HTTP_HOST} ^live.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.live.com$
RewriteRule (.*)$ http://www.live.com/index.html [L]

谢谢!

1 个答案:

答案 0 :(得分:0)

# Disable live domain
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?live\.com$
RewriteCond $1 !^index\.html
RewriteRule ^(.*)$ http://www.live.com/index.html [L]