1. Since version 1.57.0: The ‘Force Redirect’ to add or omit www needs an Apache implementation change to preserve website security headers on the HTTPS redirect response.
    Current explanation by DirectAdmin: https://www.directadmin.com/features.php?id=2365 (https://www.directadmin.com/features.php?id=2234)
  2. Let’s Encrypt certificates: An obsolete and unnecessary example.com.san_config file can interfere with the selected key algorithm during automatic renewal. DirectAdmin’s administration or migration process can remove this legacy file.

DirectAdmin Force Redirect — Preserving Security Headers

DirectAdmin provides a Force Redirect function to select the canonical www or non-www hostname. The redirect works, but with the current Apache implementation an HTTPS 301 response can be generated without the security headers configured by the website in .htaccess.

Apache provides a relatively simple alternative that is not widely recognised: DirectAdmin’s existing rewrite can be placed in the existing <Directory> context of the normal HTTPS virtual host.

<Directory "/home/USER/domains/DOMAIN/public_html">
    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www\.DOMAIN$ [NC]
    RewriteRule ^ https://www.DOMAIN%{REQUEST_URI} [R=301,L,NE]
</Directory>

DirectAdmin remains responsible for the Force Redirect and does not need to modify .htaccess. Apache can then apply the website’s existing security-header configuration to the redirect response.

Reproducible test

On 24 September 2026 this was tested with webdomeindienst.nl, over both IPv4 and IPv6. With DirectAdmin’s Force Redirect moved from virtual-host rewrite context to the existing <Directory> context, the non-www 301 included the website’s existing Content-Security-Policy, X-Content-Type-Options, Referrer-Policy and X-Frame-Options.

The result was independently visible in the Multifold measurement at 15:05 UTC. (multifold.hostingtool.org)

After restoring DirectAdmin’s current configuration, those website headers disappeared from the 301 again while remaining present on the canonical www response. This provides a straightforward A/B/A test of the processing difference.

HSTS can also be application-managed. In particular, preload should not be added automatically when the domain-level HSTS configuration does not explicitly request it.

Applicability beyond DirectAdmin

On 29 November 2026, the same directory-level rewrite approach was successfully implemented and tested with workingornot.org on a standalone Apache 2.4.66 server running Ubuntu, without DirectAdmin.

The configuration uses a single HTTPS virtual host for both the canonical and non-canonical hostnames, with a shared security-header configuration using Header always set.

Testing over both IPv4 and IPv6 confirmed:

  • HTTP-to-HTTPS redirection preserving the original hostname.
  • Canonical hostname redirection within the <Directory> context.
  • Identical security headers on HTTPS 301 and 200 responses.
  • Correct handling of the security.txt redirect.
  • Successful simulated automatic Let’s Encrypt certificate renewal.

The results demonstrate that directory-level canonical hostname redirection is not merely a workaround for DirectAdmin, but a reusable Apache configuration pattern that avoids unnecessary duplication of virtual hosts and security-header configuration.

The relevant Apache configuration is:

<VirtualHost *:80>
    ServerName workingornot.org

    RewriteEngine On
    RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/
    RewriteRule ^ https://workingornot.org%{REQUEST_URI} [R=301,L]
</VirtualHost>

<VirtualHost *:80>
    ServerName www.workingornot.org

    RewriteEngine On
    RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/
    RewriteRule ^ https://www.workingornot.org%{REQUEST_URI} [R=301,L]
</VirtualHost>

<VirtualHost *:443>
    ServerName www.workingornot.org
    ServerAlias workingornot.org
    DocumentRoot /var/www/workingornot.org/public_html

    SSLEngine On
    SSLCertificateFile /etc/letsencrypt/live/workingornot.org/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/workingornot.org/privkey.pem

    <Directory /var/www/workingornot.org/public_html>
        Options -Indexes +FollowSymLinks
        AllowOverride None
        Require all granted

        RewriteEngine On
        RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/
        RewriteCond %{HTTP_HOST} !^www\.workingornot\.org$ [NC]
        RewriteRule ^ https://www.workingornot.org%{REQUEST_URI} [R=301,L,NE]
    </Directory>

    SetEnv no-gzip 1
    Header always set Strict-Transport-Security "max-age=63072000"
    Header always set X-Content-Type-Options "nosniff"
    Header always set Referrer-Policy "same-origin"
    Header always set X-Frame-Options "DENY"
    Header always set Content-Security-Policy "default-src 'none'; base-uri 'none'; frame-ancestors 'none'; frame-src 'none'; form-action 'self'; img-src 'self'; font-src 'self'; style-src 'self' 'unsafe-inline'; script-src 'none'; connect-src 'none'; object-src 'none'"
    Header always set Permissions-Policy "camera=()"

    ErrorDocument 404 /404.html

    Redirect 302 /.well-known/security.txt https://janwillemstegink.nl/.well-known/security.txt

    ErrorLog ${APACHE_LOG_DIR}/workingornot.org-error.log
    CustomLog ${APACHE_LOG_DIR}/workingornot.org-access.log combined
</VirtualHost>

The configuration separates HTTP-to-HTTPS redirection from canonical hostname redirection, while maintaining a single HTTPS virtual host and a single security-header configuration. ACME challenge handling is provided through a shared Apache Alias configured separately.

Different web-server configurations

The demonstrated solution applies to Apache. With nginx + Apache, the determining question is whether nginx performs the canonical redirect before the request reaches Apache; if so, Apache and .htaccess cannot contribute to that response.

DirectAdmin’s OpenLiteSpeed template uses autoLoadHtaccess 1 together with FORCE_SSL_REDIRECT in its rewrite configuration. Its resulting behaviour should be tested separately rather than assumed to be identical to Apache or nginx.

For Apache, the tests show that no new “merged mode” is required. A small change in the processing context of DirectAdmin’s existing Force Redirect can preserve the separation between hosting-platform configuration and application configuration while allowing both to contribute correctly to the HTTPS response.

The same configuration principle is applicable to independently managed Apache environments, providing a consistent approach to canonical hostname redirection and defense-in-depth.