Hey everyone, I'm definitely a newb when it comes to internet backend stuff wanted to see if you guys could shed some light for me. On the backend of Wordpress I changed my general settings for both Site Address URL and Wordpress Address URL from http to https. It seems to have worked but if I type in the URL with http it doesn't automatically redirect to https like I thought it would. Basically HTTP & HTTPS protocols works apart and return the same page content. My friend tells me I should use the following code in my .htaccess to set up a 301 redirect: RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https: //%{HTTP_HOST}%{REQUEST_URI} [L,R=301] Is this accurate info and should I use this code? Thanks for your input.
Yes, you can use this code. Alternatively, you could also use: RewriteEngine on RewriteCond %{SERVER_PORT} ^80$
I'm sorry, I was unable to post the last line but it's the same one as yours. For some reason, the forum won't let me post it.
open .httaccess and write that RewriteEngine On RewriteBase / RewriteCond %{HTTPS} off RewriteCond %{HTTP:X-Forwarded-Proto} !https RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] Code (markup):
For anyone else looking to do the same, here's also a useful article that breaks down the entire process from start to finish: https://websitesetup.org/http-to-https-wordpress/
If you want to change from HTTP to https then make sure that your server has an SSL certificate installed and activated for your domain. Nowadays most of the shared hosting providers offer free SSL but if you are using hosting which does not offer free SSL then you should purchase one or you can go with free SSL providers like Cloudflare or letsencrypt. Another thing is all the links in your theme must use https for the resources. otherwise, the browser will give a warning to the visitor. If you do not want to modify your code then you can use this plugin to sort your theme links issue. https://wordpress.org/plugins/ssl-insecure-content-fixer/