Forcing HTTPS in DirectAdmin

7 vues Security & SSL

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

  1. Log in to DirectAdmin and navigate to Account Manager → SSL Certificates.
  2. Check the box labeled Force SSL with https redirect.
  3. 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;
}
After enabling HTTPS redirection, update your website's internal links and settings (e.g., WordPress Site URL) to use https:// to avoid mixed content warnings.

Verifying the Redirect

  • Open a browser and visit http://yourdomain.com. You should be automatically redirected to https://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.
Besoin d'aide ?

Vous ne trouvez pas ce que vous cherchez ? Notre équipe de support est prête à vous aider.

Contacter le support
Bonjour ! Comment pouvons-nous vous aider ?
Discuter