.htaccess - htaccess RewriteRule for www / https not working if both conditions present -


i'm running problem .htaccess rewrite rules , wondered if help.

i have set redirects non-www. url www. need introduce https redirect. after looking while found first example below, however, causing redirect loop error in browsers.

the 2nd example works fine scenarios except visit www.example.com doesn't direct https. know of way around @ all?

# redirect loop rewritecond %{server_port} !=443 [or] rewritecond %{http_host} !^www\. rewriterule ^(.*)$ https://www.website.com/$1 [r,l]   # works (without ssl redirect) rewritecond %{http_host} !^www\. rewriterule ^(.*)$ https://www.website.com/$1 [r,l]  

i've tried following conditions result in same error

rewritecond %{https} off rewritecond %{server_port} 80  

full htaccess

<ifmodule mod_rewrite.c>     rewriteengine on     options +followsymlinks     rewritebase /      rewritecond %{http_host} !^www\. [nc,or]     rewritecond %{https} off     rewritecond %{http_host} ^(?:www\.)?(.+)$ [nc]     rewriterule ^ https://www.%1%{request_uri} [r,l,ne]      # removes index.php urls     rewritecond %{the_request} ^get.*index\.php [nc]     rewritecond %{request_uri} !/system/.* [nc]     rewriterule (.*?)index\.php/*(.*) /$1$2 [r=301,ne,l]      # directs traffice through site index     rewritecond %{request_filename} !-f     rewritecond %{request_filename} !-d     rewriterule ^(.*)$ /index.php?/$1 [l] </ifmodule> 

you can use single rule add www , https:

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

make sure replace both of rules rule , clear browser cache.


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -