.htaccess - htaccess redirect all traffic to https://www -


i'm trying redirect 3 cases https://www. are:

http://
http://www
https://

i've been able first two, not last one. here's i'm using that:

rewritecond %{https} off
rewritecond %{http_host} ^(?:www\.)?(.*)$ [nc]
rewriterule (.*) https://www.%1%{request_uri} [l,r=301]

you can use rule add www , turn on https in same rule:

rewritecond %{http_host} !^www\. [nc,or] rewritecond %{https} off rewritecond %{http_host} ^(?:www\.)?(.+)$ [nc] rewriterule ^ https://www.%1%{request_uri} [r=301,l,ne] 

to capture value %{http_host} need condition not or condition.


Comments

Popular posts from this blog

Capture and play voice with Asterisk ARI -

java - Why database contraints in HSQLDB are only checked during a commit when using transactions in Hibernate? -

visual studio - Installing Packages through Nuget - "Central Directory corrupt" -