开发者

.htaccess redirect excluding sub-domains

I have the following in my .htaccess to redirect all old domain names which point to the same location to the new domain, but this doesn't allow any sub dom开发者_如何学JAVAains of the new domain name to work - any idea how to amend the code to allow sub-domains would be appreciated:

RewriteCond %{HTTP_HOST} !^www\.newdomain\.com$ [NC]
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [R=301,L]


Redirect subdomain to subdomain under a new domain...

RewriteCond %{HTTP_HOST} ^(.*)\.domain\.com$ [NC]  
RewriteRule ^(.*)$ http://%1.newdomain.com/$1 [R=301,L]


Thanks Brian - it certainly helped - the final outcome is the following:

RewriteCond %{HTTP_HOST} !^www\.newdomain\.com$ [NC] [AND]
RewriteCond %{HTTP_HOST} !^(.*)\.newdomain\.com$ [NC]  
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [R=301,L]

Thanks for your time.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜