0

I would like to force all visitors to access my website on https://

Does this look standard and SEO friendly?

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{HTTPS} !=on
    RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [L,R=301]
</IfModule>

1 Answer 1

0

Anyone of the following would work

RewriteEngine on RewriteCond %{HTTPS} !=on RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [L,R]

RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [L,R]

Be careful with the R=301 redirect. Once a browser loads one of those, it stores it FOREVER ! If you ever want to go change the redirect it becomes very hard to do. Use a R or R=302 instead to start with.

1
  • But if you always want to use https and never http then 301 is what google recommends.
    – wogsland
    Feb 12, 2017 at 16:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .