开发者

htaccess sitea.com/1 to siteb.com/1

开发者 https://www.devze.com 2023-02-06 01:43 出处:网络
i want to create with htaccess that if you go to www.website1.com/page.php that you go to w开发者_JAVA技巧ww.website2.com/page.php, and www.website1.com/foo/bar/index.php to www.website2.com/foo/bar/i

i want to create with htaccess that if you go to www.website1.com/page.php that you go to w开发者_JAVA技巧ww.website2.com/page.php, and www.website1.com/foo/bar/index.php to www.website2.com/foo/bar/index.php redirects. How can i do that with htaccess? Example please.


If mod_rewrite is available, you can put this code into the .htaccess of www.website1.com:

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

This would redirect every page on website1.com to the equivalent on website2.com

0

精彩评论

暂无评论...
验证码 换一张
取 消