将域名重定向到同一个域?

时间:2012-04-03 20:11:58

标签: redirect apache2

我想将以下域名重定向:haloservers.net,haloservers.nl和servers.xgclan.com到域名www.haloservers.us 我尝试将下面的代码放在htaccesses文件中,但这不起作用。

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.?)haloservers.net$
RewriteRule ^(.*)$ http://www.haloservers.us/$1 [R=301,L]

RewriteCond %{HTTP_HOST} ^(www\.?)haloservers.nl$
RewriteRule ^(.*)$ http://www.haloservers.us/$1 [R=301,L]

RewriteCond %{HTTP_HOST} ^(servers\.)xgclan.com$
RewriteRule ^(.*)$ http://www.haloservers.us/$1 [R=301,L]

2 个答案:

答案 0 :(得分:0)

尝试:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?haloservers\.net [NC]
RewriteRule ^(.*)\.html$ http://haloservers.us/$1 [R=301,L]

答案 1 :(得分:0)

以下代码解决了问题。

RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^(.*)haloservers(.nl|.net)$ 
RewriteRule ^(.*) http://www.haloservers.us/$1 [L,R=301]
RewriteEngine On RewriteCond %{HTTP_HOST} ^(www\.)?haloservers(.nl|.net) [NC]
RewriteRule ^(.*)\.html$ http://haloservers.us/$1 [R=301,L]

我从col-dejong @ http://gathering.tweakers.net/forum/list_messages/1497390/last

获得了我的解决方案