开发者

301 redirect match problem

Ok I am serving two domains off of one box. The domains are:

www.old.org and www.new.com. As it is now, all of the files and dirs are the same on both domains.

I want to make it so that IF someone goes to www.old.org/folder_a/file_b.php they are 301'ed to www.new.com/folder_a/file_b.php.

I've already tried in the htaccess:

RedirectMatch 301 ^/ http://www.new.com/

But that give a 301 loop because the 301's condition still applies after 开发者_JS百科the 301 is enacted. I think I want to do something that uses rewritecond %{HTTP_HOST} ^.*old.org$ so that only url's at old.org or www.old.org will be affected, but I'm not sure how to do this.


If you have access to the apache vhost configs use those instead of the .htaccess:

<VirtualHost *:80>
    ServerName www.old.org
    Redirect permanent / http://www.new.com/
</VirtualHost>

If you really must use an .htaccess the following will do:

RewriteEngine On
RewriteCond %{SERVER_NAME} =www.old.org [NC]
RewriteRule (.*) http://www.new.com/$1 [R=301,L]


Some thing like this should do:

RewriteCond %{http_host} ^www\.old\.org$ [NC]
RewriteRule ^/(.*) http://www.new.com/$1 [R=301]
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜