I’ve just purchased an SSL certificate for a WordPress site and want people to go to https://www… rather than http://www..
I’ve read that you need to change the Change the WordPress Address (URL) and Site Address (URL) within the dashboard in Settings – General.
I also read that you need to add in a redirect within an .htaccess file with:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.domain.com [NC]
RewriteRule ^(.*)$ http://domain.net/$1 [L,R=301,NC]
Do I need to do both?
If yes, does the above code get placed within the default WordPress .htaccess code or would it appear above it?
Thanks
try adding this on to your functions.php instead of changing something in to your .htaccess
or refer to this plugin: HTTP Redirect
I am not much use at .htaccess rules, but I know that’s not the rule I use. In conjunction with changing the WordPress Address and Site Address (as you point out), I change the default WordPress .htaccess to
However if it’s an existing site you are going to run into the issue that your database is riddled with content full of image links using the
http
protocol which will break your padlock in the browser. Rather than editing all the posts, I use this tool;https://interconnectit.com/products/search-and-replace-for-wordpress-databases/
(Most folk use it when transferring a WP site from one domain to another) and just rename all the images in the database by replacing all instances of
http://www.example.com
withhttps://www.example.com
you can run
code
inside yourfunctions.php
You can also use code inside
.htaccess
RewriteEngine On RewriteCond %{HTTPS} !on RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
Both works, but use ony one, not both.