Force WordPress to use SSL: When youre using SSL on your WordPress-powered website youll know that simply changing your websites url in the setting isnt enought, it will redirect the homepage to your HTTPS version, but when a user goes to example.com/blog it wont redirect to HTTPS, this can cause trouble with including stylesheets etc. Now, you can use a plugin to fix this but if youre like me and dont want to use plugin unless absolutely necessary you can do this yourself.
Without a plugin
.htaccess
Simply add the following code to your .htaccess file will make it work.
# BEGIN WordPress RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule ^(.*) https://%{SERVER_NAME}/$1 [R,L] RewriteRule ^index.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] # END WordPress
Javascript
Or you can add the following piece of Javascript to your site.
<script>
if (document.location.protocol != "https:") {
document.location = document.URL.replace(/^http:/i, "https:");
}
</script>
With a plugin
Ofcourse you can also use a plugin to do this for you, I myself use Really Simple SSL and would highly recommend it.