Redirecting All HTTP Traffic to HTTPS
After installing an SSL certificate, you should redirect all HTTP requests to HTTPS to ensure visitors always use the secure version of your site. There are two main ways to accomplish this in DirectAdmin.
Method 1: Using DirectAdmin's Built-in Option
- Log in to DirectAdmin and navigate to Account Manager → SSL Certificates.
- Check the box labeled Force SSL with https redirect.
- Click Save.
This method automatically adds the necessary redirect rules to your Apache or Nginx configuration without requiring manual file edits.
Method 2: Using .htaccess (Apache)
If you need more granular control, add the following rules to the .htaccess file in your domain's public_html directory:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
This creates a 301 permanent redirect from HTTP to HTTPS for all pages.
Method 3: Nginx Configuration
If your server uses Nginx (or OpenLiteSpeed), the .htaccess method will not work. Instead, DirectAdmin allows custom Nginx configuration. Create or edit the custom Nginx config for your domain:
if ($scheme = http) {
return 301 https://$host$request_uri;
}
https:// to avoid mixed content warnings.Verifying the Redirect
- Open a browser and visit
http://yourdomain.com. You should be automatically redirected tohttps://yourdomain.com. - Use browser developer tools (Network tab) to confirm you receive a 301 status code for the redirect.
- Check for mixed content warnings by looking at the browser console for any resources still loading over HTTP.