开发者

htaccess direct domain and subdomain?

开发者 https://www.devze.com 2023-01-17 11:35 出处:网络
I have开发者_运维知识库 a problem where I want to redirect all traffic [301 permanent] from www.example.com --> www.website2.com

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

精彩评论

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

关注公众号