.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

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -