Ask or search…
Comment on page

HTTPS redirection

For securing communications with your visitors, we recommend redirecting visits to your site using HTTPS.


  • a Web Hosting service
  • an OnetSolutions account


To achieve this, you can modify or create the .htaccess file in your website's root directory and add the following code:
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTPS} !on
RewriteRule ^(.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
This code snippet checks if the X-Forwarded-Proto header is not set to "https" and if the HTTPS environment variable is not enabled. If both conditions are met, it redirects the visitor to the HTTPS version of the site using a 301 (Permanent) redirect.
To ensure the security of your entire content, including images and other assets, it's essential to update any references or links to use the HTTPS protocol instead of HTTP. This ensures that all elements on your website are loaded securely over HTTPS.
By implementing these steps, you can enforce HTTPS for your site, providing a secure browsing experience for your visitors and safeguarding their interactions with your website.