Automatically Redirect Visitors to SSL-Secured Site

For Linux Web Hosting and Managed Dedicated Server and Windows Web Hosting packages

Learn how to automatically redirect your visitors to the HTTPS address of the website after setting up your SSL certificate. This method uses a 301 redirect (permanent redirect) that is search engine friendly.

Those using a content management system (CMS) such as WordPress, Joomla!, Typo3, or a shop system (e.g. Prestashop, Magento) will find their instructions here.

MyWebsite and Managed WordPress packages automatically redirect traffic to the HTTPS address when the SSL certificate is activated. No additional steps are necessary.

Steps for Linux Packages

  • Open a basic text editor, such as Notepad (Windows) or TextEdit (MacOS).
  • Copy and paste the code below into your text editor.
  • RewriteEngine On
    RewriteCond %{SERVER_PORT} !=443
    RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]
  • In the text editor, replace "example.com" with your own domain.
  • Save the file as .htaccess and choose to Save as type: All Files (*.*) underneath the file name.
  • Upload the File Using WebspaceExplorer to the root of your webspace.

Once the file is uploaded, the redirect should take effect. Open your web browser and enter your domain. Confirm that the browser redirects from http:// to https://.

Steps for Windows Packages

  • Open a basic text editor, such as Notepad (Windows) or TextEdit (MacOS).
  • Copy and Paste the code below into the text editor.
<%EnableSessionState=False
host = Request.ServerVariables("HTTP_HOST")

if host = "example.com" or host = "www.example.com" then
response.redirect("https://www.example.com/")

else
response.redirect("https://www.example.com/error.htm")

end if
%>
  • In the text editor, replace all instances of "example.com" with your own domain.
  • Save the file as default.asp.
  • Upload the File via FTPS to the root of your webspace.
  • Once the file is uploaded, the redirect should take effect. Open your web browser and enter your domain. Confirm that the browser redirects from http:// to https://.

    Troubleshooting

    • The website does not load anymore after the redirect (error 500): If you get an 500 error when visiting the website, it is likely there is a typo or some other hidden formatting (the latter can happen if the .htaccess file was created with Microsoft Word instead of a basic text editor). Simply delete the file from your webspace, make the corrections to the file on your computer, and then upload the corrected file again.
    • The browser displays a mixed content warning: If browsers still classify your website as insecure after the redirect and display a mixed-content warning, more action is required. You can find more information about this explained in our community article Detect and Remove Mixed Content: Enabling Encryption for All Content.