Explore our in-depth
crafted by
skilled professionals!

Our Latest News, Advice and Thoughts

Redirect Website /Path to Use HTTPS in DirectAdmin

You are here:

These days, In case you are not utilizing an SSL certificates in your web site, guests may not belief your web site. Google too, prefers websites with SSL over the websites that don’t have SSL certificates. On this tutorial, we’ll see the way to redirect our web site from http to https robotically for all of the customers. If you wish to set up SSL on Nginx or Set up SSL on Apache, you possibly can comply with our guides.

It’s time to redirect our guests from non-secure HTTP URLs to safe HTTPS URLs. There are numerous strategies to carry out this process. We are going to go together with the very best.

To redirect web site guests from HTTP to HTTPS forcefully, we simply have so as to add few traces within the .htaccess file on our server. You may create a .htaccess file within the DocumentRoot of the area or hostname you want to redirect from HTTP to HTTPS. After creating the .htaccess file, add the next traces in it. If you have already got .htaccess file out there in your server, Simply append these traces within the file.

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

The above-given code will switch any non-https connections to https utilizing the identical request and GET variables. And within the case of Cloudflare, there could be a small change within the code, provided that your website is operating by means of Cloudflare, your https requests may very well hit your server on HTTP port. Use the next code if you’re utilizing Cloudflare.

RewriteCond %HTTPS off RewriteCond %HTTP:X-Forwarded-Proto !https RewriteRule (.*) https://%HTTP_HOSTpercentREQUEST_URI [R,L]

To Settle for Globally in Apache

To use this rule to all of the domains below the server, comply with the steps given beneath.

1) For accepting globally within the Apache, to begin with, we have to create a world config file. The placement of the file ought to be as given beneath.


Then add the next code in that file.


2) After that, we wish to use the variable, so create a file on the following location with the identical identify.


Now, Add the next code into the file in case of Apache.

|*if SSL_REDIRECT_HOST!=""| Redirect / https://|SSL_REDIRECT_HOST"https://www.webhostingpeople.web/"*endif|

Within the case of Nginx, the code shall be a bit of completely different. Right here is the code for Nginx.

|*if SSL_TEMPLATE="0"| return 301 https://$host$request_uri; |*endif|

3) And if you wish to allow https for all area besides one, then inside the identical code you possibly can specify it. To disable it for just one area identify, go to:

Admin Stage -> Customized Httpd Config -> area.com

and within the CUSTOM token textual content space, add this textual content.


This may make the variable clean and the precise area identify shall be excluded from the rule.

4) Then must rewrite the configs to make use of it.

cd /usr/native/directadmin/custombuild

./construct rewrite_confs

So that is the way you redirect web site from HTTP to HTTPS. It’s all the time an excellent observe to redirect from HTTP to HTTPS. It can shield the info that guests will enter in your website. Should you want any additional assist, please do attain our help division.

Leave a Comment