Thursday, 15 April 2010

.htaccess - htaccess redirect domain to https, subdomain to http and www to non-www -


I'm trying to:

Force https for your main domain.

  http or https://www.domain.com - & gt; Https://domain.com http or https://domain.com - & gt; Http: //domain.com  

but not for subdomain

  http or https://www.subdomain.domain.com - & gt; Http://subdomain.domain.com http or https://subdomain.domain.com - & gt; Http://subdomain.domain.com  

and always delete www.

Now I have this:

  rewrite% {HTTP_HOST} ^ www. (. *) $ [NC] Rewriteume ^ (. *) $ Http: //% 1 / $ 1 [R = 301, L] Revaccount% {HTTPS} of Ritmt Raul (. *) Https: //% {HTTP_HOST }% {REQUEST_URI} [R = 301, L]  

This redirects from www to non-www and http to https, but not for subdomains. The subdomain stays with www and https.

Thanks

You can use these 2 rules: the main domain rewrite angle For #% {HTTP_HOST} ^ (www \.)? Domain \ .com $ [NC] restarted% {HTTPS} close [or] rewrite% {HTTP_HOST}} ^ www. [NC] REERTRL: https: //domain.com% {REQUEST_URI} [R = 301, L, NE] #% rewrite for subdomain% {HTTP_HOST} ^ (www.)? Subdomain \ .domain \. Comm $ [NC] [OR] Revoked code% {HTTP_HOST} ^ www. Rev. Kandan% {HTTPS}. [NC] REERTrial ^ http: //subdomain.domain.com% {REQUEST_URI} [R = 301, L, NE]


No comments:

Post a Comment