Reputation: 1365
I included the following lines of code in my htaccess
file to redirect users to the HTTPS
version of my site.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ https://www\.mysite\.com%{REQUEST_URI} [R=301,L]
</IfModule>
When I type mysite.com
or www.mysite.com
into the address bar it works perfect and sends me to the HTTPS
version.
However if I go to Google, search for my site and click the link from the search results it still takes me to the HTTP
version. I have 3 questions on this.
1) Why doesn't the browser automatically redirect once the user makes contact with the server and my htaccess
file?
2) Shouldn't HTTP
be turned off once HTTPS
is turned on?
3) To completely make the switch do I need to use redirects or something similar from inside the Godaddy control panel?
Thanks so much!
Upvotes: 0
Views: 28
Reputation: 18671
Use:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www\.mysite\.com%{REQUEST_URI} [R=301,L]
</IfModule>
With [OR]
because now you redirect only http without www.
Clear your browser cache before testing.
Upvotes: 1