开发者

.htaccess redirect excluding sub-domains

开发者 https://www.devze.com 2023-03-19 22:57 出处:网络
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 nam

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

精彩评论

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

关注公众号