开发者

htaccess direct domain and subdomain?

I have开发者_运维知识库 a problem where I want to redirect all traffic [301 permanent] from

www.example.com --> www.website2.com
blog.example.com --> blog.example.com

So redirect all domains/subdomains on "Example.com" to website2.com EXCEPT for the blog on example.com ? Little unsure how to set this up using .htaccess on "example.com" ?

Really appreciate any help.


Somewhat similar to this question:

RewriteCond %{HTTP_HOST} !(^blog\.example\.com$)  
RewriteRule (.*) http://www.website2.com/$1 [R=permanent,QSA,L]

Line by line:

In case the Host: header ("%{HTTP_HOST}") is not ("!") blog.example.com (no other string matches that regex), execute the following rewrite:

for a pattern matching anything (".*", that is, for any URL), redirect to the same path on www.website2.com (e.g. http://blahblah.example.com/somepath will get redirected to http://www.website2.com/somepath ).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜