Change to HTTPS

I was wondering if anyone has any good advise on changing my website(s) to HTTPS. All my sites have it built in my control panel and they all work typing http or https. I changed it in my Google Console but how do I make my website default to HTTPS? Also, do I have to change the default to the S in bloc project manager?

Any advice would greatly appreciated. I’m no coder…

Casey

You need a 301 redirect like this as htaccess:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*)
RewriteRule ^.*$ https://%1/$1 [R=301,L]

RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

There are other alternatives, but that works for me. Just create a new document on the server using your FTP client. Paste in that code and save it as .htaccess

Everything should now default to https://

4 Likes

Thank you. It worked perfect.

Casey

On your other question about the project settings if you want Blocs to produce a sitemap then you should change it to https:// but if you want to upload your sitemap separately via some other means as I do then leave that field blank.

1 Like

Flashman I was able to get all my new site upgraded to HTTPS. Thank you very much.

I have one more question, maybe you could help. I have a few older sites that have older .htaccess files with a lot of other information. Some had older coding and forms that required coding.

Should I just delete the old info and all your code or maybe just add the new code you provided? If so, add first?

Casey

That’s very difficult to say without seeing your old htaccess files and I’m not a huge expert. First of all I would start by looking at your old htaccess and ask if you really need it all or if changes can be made in other ways, such as via the forms. If you do need them, then try disabling your old htaccess file, which can be done by removing the dot at the start of the name.

Keep the new code at the top of your live htaccess file, then try pasting in other bits one at a time and testing to see if it breaks anything.

Thanks, I looked close at each one and I didn’t see anything I needed. I backed up the original one and then created a new one with your code. Everything seems to be working correctly.

Again, Thank You.

Casey

No worries, glad you are sorted. It’s worth reviewing htaccess files from time to time just to make sure they are still relevant.

2 Likes