Mobile app version of vmapp.org
Login or Join
Nimeshi995

: Htaccess force ssl I need to force all traffic for all pages on example.com to https://www.example.com . After much googles, and hosting site help docs, the consensus (and what my hosting -

@Nimeshi995

Posted in: #Htaccess #Https

I need to force all traffic for all pages on example.com to www.example.com . After much googles, and hosting site help docs, the consensus (and what my hosting - BlueHost - docs say to do) is this:

RewriteEngine on
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ www.example.com/ [R]


Which seems like it should work. But when I type in just example.com in a browser (FF or Chrome), the request is redirected to
www.example.com/https:/www.example.com/

The rule is at the top of the htaccess file, so don't understand why this is happening.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Nimeshi995

1 Comments

Sorted by latest first Latest Oldest Best

 

@Ogunnowo487

RewriteRule ^(.*)$ www.example.com/ [R]



You probably need the L (last) flag. ie. [R,L]. Otherwise, with this directive being at the top of the .htaccess file, processing will continue through the file and it's likely to be rewritten again - so literally anything could happen. (I would be surprised if the Bluehost docs did not include this?)

Also, once you have confirmed this is working OK, you should change this to a permanent (301) redirect. ie. [R=301,L].

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme