Automatically redirect website to https://
Do you want to automatically redirect visitors to https:// as soon as they visit your site via http://? For this, a piece of code needs to be placed in the .htaccess file.
It is important to ensure that an SSL certificate is present. Otherwise, visitors will receive a warning that the website is not secure. To install a free Let's Encrypt SSL certificate, check this link.
When the SSL certificate is installed and the SSL connection works via https://, you can ensure that all traffic is automatically redirected from http:// to https:// to force a secure SSL connection.
Creating the .htaccess file
To ensure that all visitors use the secure SSL / HTTPS connection, a few lines of code must be placed in the .htaccess file. Log in via FTP, or via the DirectAdmin file manager. The .htaccess file can be found in the following folder:
/domains/uw-domein.nl/public_html/
If there is no .htaccess file present, you can create one.
Redirecting visitors to HTTPS
Place the following code in the .htaccess file to redirect visitors to the HTTPS website:
# Forceer HTTPS verbinding
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
Save the .htaccess file and the redirect is active! Do you only want to create this redirect for a subfolder or subdomain? Then go to the relevant folder, under public_html, and create the .htaccess file there with the above code.
Redirecting to HTTPS for WordPress
For WordPress, there is also an easier method, which requires no code adjustments.
To automatically redirect visitors of your WordPress website to the secure SSL / HTTPS connection, you can use the WordPress plugin "Really Simple SSL". Install this plugin in the WordPress admin.
After installing this WordPress plugin, pages are automatically redirected to the https:// version.
Still have questions? Get in touch.