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>
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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.