Here is the code I’m using to always add https and www to my code.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com$ [OR]
RewriteCond %{HTTPS} !on
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
I’ve read about making the redirect = 301 and was wondering if and how I should do that?
2
Answers
301 redirect is used for permanent URL redirection so, in your case,
[R=301,L]
should be used.Google states this:
And also according to Google HTTPS directions 301 redirect is considered a best practice for HTTPS redirects.
It’s good to have 301 redirection, much better than 401 (google doesn’t like it).