htaccess sitea.com/1到siteb.com/1

时间:2011-01-23 17:15:27

标签: .htaccess redirect

我想用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做到这一点?请举例。

1 个答案:

答案 0 :(得分:2)

如果mod_rewrite可用,您可以将此代码放入.htaccess的{​​{1}}中:

www.website1.com

这会将RewriteEngine on RewriteCond %{HTTP_HOST} ^(www\.)?website1\.com$ RewriteRule ^(.*)$ http://www.website2.com/$1 [L,QSA,R=301] 上的每个页面重定向到website1.com

上的等效内容