HTTP to HTTPS redirection
Hi all
Sorry if this is simple and I should be chastised for not looking harder.
I have a web site written I Xara. Works fine!
I paid my host to implement HTTPS on their end, It works if you enter HTTPS:// my website domain
How ever a search shows the HTTP version and I want to force a redirection to HTTPS
No idea how to do it? Is it something I add in the settings or do I need to write some code or what?
Many Thanks
Tim
1 Attachment(s)
Re: HTTP to HTTPS redirection
I do mine by adding a .htaccess file to the public_html folder (same place as you upload your site to). An .htaccess file is a text file created in Notepad or similar with the file extension (.txt) removed and are literally named .htaccess.
I have seen different versions that achieve the same job, but mine is:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Attachment 130594
Re: HTTP to HTTPS redirection
This code works for me, it's useful if you have subdomains.
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R=301,NE,L]
Re: HTTP to HTTPS redirection
Thanks
Just to be sure I can use the code as is? No need to add URL names eg mywebsite.com
Tim
Re: HTTP to HTTPS redirection
Quote:
Originally Posted by
TimBox
Thanks
Just to be sure I can use the code as is? No need to add URL names eg mywebsite.com
Tim
Speaking for my post only...fine as is, just copy/paste.
Re: HTTP to HTTPS redirection
YAY!!!!!
As always chaps great advice and you fixed my issue. Works a treat. Many many thanks...
Tim
Re: HTTP to HTTPS redirection
Quote:
Originally Posted by
TimBox
YAY!!!!!
As always chaps great advice and you fixed my issue. Works a treat. Many many thanks...
Tim
Hey, just one other thing you might want to check (and I'm sure there will be an answer on this forum somewhere).
I had this redirect issue - my site showed https and also http (and Google saw them as two different sites). I also had an issue where I had www.mysitename.co.uk and mysitename.co.uk. This was a real pain as, if I understand it correctly, Google saw four sites all duplicated;
https://www.mysitename.co.uk
http://www.mysitename.co.uk
https://mysitename.co.uk and
http://mysitename.co.uk.
My issues are all solved - but I know I hadn't realised all of these problems were there. Hopefully you don't have this issue, but I thought it was closely related and worth mentioning.