Categories: Website

How to force SSL (redirect) using .htaccess

STATIC / CUSTOM WEBSITES

When your website has SSL enabled, you may want to force all traffic to be served over the SSL encrypted connection only. This can easily be achieved by adding the code below in your .htaccess file. If you have any redirect codes in your .htaccess file, we recommend adding this before that and verifying that no other redirect code is redirecting back to http:// non-SSL URLs.

The code to be added in your .htaccess file is as follows.

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

If that does not work for some reason, alternate code below can be use. Replace domainname.com with your own domain in the code below.

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.domainname.com/$1 [R,L]

WORDPRESS WEBSITES

To enable SSL for WordPress websites, please follow the steps below:

  • Log in to WordPress as the administrator.
  • On the left-hand menu, click Settings, and then click General.
  • Under General Settings, in the WordPress Address (URL) text box, replace the current http:// URL with the secure https:// URL of your website such as https://www.yourdomain.com
  • Use the same URL in the Site Address (URL) texts box as well
  • Click Save Changes.
Admin

Share
Published by
Admin

Recent Posts

Enable Outgoing SMTP Server Authentication

All our servers need you to enable outgoing SMTP server authentication to be able to…

4 years ago

Plesk Tutorials – How to configure DNS for a domain in Plesk

Learn how to configure and check your DNS settings in Plesk. After you registered your…

5 years ago

cPanel Tutorials – Force HTTPS Redirect

This video demonstrates how to use the Force HTTPS Redirect feature. This feature allows you…

5 years ago

cPanel Tutorials – MultiPHP Manager

Use cPanel's MultiPHP Manager to manage your domains' PHP version. Being able to manage the…

5 years ago

Email account setup in Outlook 2016

This tutorial will help you to configure Microsoft Outlook 2016 for an email account. Step…

5 years ago

Message Queueing

Generally emails are directly delivered to the destination server. However, if the delivery attempt to…

5 years ago