Knowledge Base » Blog Archive » How to force SSL (redirect) using .htaccess

How to force SSL (redirect) using .htaccess

August 4th, 2016

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. Replace domainname.com with your own domain.

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.