linux - Redirecting non-www to www, but keeping other sub-domains intact -


i have 5 web pages different domain names. each of them uses same directory , same .htaccess file. i've redirected non www urls www lines:

rewritecond %{http_host} !^www\. rewriterule ^(.*)$ http://www.%{http_host}/$1 [r=301,l] 

now keep redirecting non wwws wwws, keep other subdomains without www. example: domain1.com should redirect www.domain1.com , subdomain1.domain1.com should still subdomain1.domain1.com , should not redirect www.subdomain1.domain1.com.

keep in mind have 5 webpages hosted same directory , there more come. don't want change .htaccess file everytime there page added.

i don't want mess .htaccess file need help!

ps: there possibility take https account. https://domain.com https://www.domain.com http://domain.com http://www.domain.com https://sub.domain.com https://sub.domain.com http://sub.domain.com http://sub.domain.com

thank in advance answers!

just target rule main domain:

rewritecond %{http_host} ^[^.]+\.[^.]+$ [nc] rewritecond %{https}s on(s)| rewriterule ^ http%1://www.%{http_host}%{request_uri} [r=301,l] 

rewritecond %{https}s on(s)| , %1 used maintain http/https in target url.

make sure clear browser cache when testing change.


Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -