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