2011-01-23 43 views
0

我想創建htaccess,如果你去www.website1.com/page.php,你去www.website2.com/page.php,和www.website1.com/foo/bar/index.php到www.website2.com/foo/bar/index.php重定向。我怎麼用htaccess做到這一點?請舉例。htaccess sitea.com/1到siteb.com/1

回答

2

如果mod_rewrite是可用的,你可以把這個代碼放到www.website1.com.htaccess

RewriteEngine on 
RewriteCond %{HTTP_HOST} ^(www\.)?website1\.com$ 
RewriteRule ^(.*)$ http://www.website2.com/$1 [L,QSA,R=301] 

這將在website1.com每個頁面重定向到等同於website2.com

+0

三江源,該訣竅。 – Thew 2011-01-23 17:26:17