Why Does .htaccess Redirect Work but DirectAdmin Site Redirection Does Not?

iPwsite

Verified User
Joined
May 9, 2020
Messages
27
Hello DirectAdmin Community,

I'm having an issue where the DirectAdmin Site Redirection feature is not working as expected for my domain, example.com, but a manual .htaccess rule works fine. I need help understanding why this is happening and how to fix the Site Redirection feature.

My Setup​

  • Domain: example.com
  • Server IP: 192.168.1.3
  • DirectAdmin Version: Latest
  • Web Server: Apache
  • SSL: Let’s Encrypt certificate installed via DirectAdmin, covering example.com
  • Website: Used for a small business

Issue​

  • Problem: example.com works. www.example.com does not work consistently with HTTPS, and https://example.com sometimes fails. I want to redirect all traffic (http://, www, etc.) to https://example.com.
  • DirectAdmin Site Redirection: I set up redirects in DirectAdmin under Account Manager > Site Redirection:
  • .htaccess Fix: I added the following to .htaccess in public_html, and it works perfectly:
    RewriteEngine On<br>RewriteCond %{HTTPS} off [OR]<br>RewriteCond %{HTTP_HOST} ^www\. [NC]<br>RewriteRule ^(.*)$ https://example.com/$1 [L,R=301]<br>
  • DNS: Confirmed with my domain provider that DNS is correct, pointing to my nameservers, with A records for both example.com and www.example.com set to 192.168.1.3.

Questions​

  1. Why does the DirectAdmin Site Redirection feature fail to redirect www and HTTP traffic to https://example.com, while the .htaccess rule works?
  2. Is there a specific configuration in DirectAdmin (e.g., Apache virtual host settings, rewrite module, or SSL settings) that I need to check or enable?
  3. Could this be related to how DirectAdmin handles Let’s Encrypt certificates or Apache configurations?

Additional Notes​

  • I’ve updated the Let’s Encrypt certificate to include www.example.com.
  • Tested in incognito mode to rule out caching issues.
  • My hosting provider manages the nameservers.
Any insights or suggestions on fixing the Site Redirection feature would be greatly appreciated! I’d prefer to use DirectAdmin’s built-in tool to avoid manual .htaccess edits for simpler management.


Thank you!
 


As far as I know DirectAdmin under Account Manager > Site Redirection can redirect only http://example.com/anything to http://another-example.com/anything

For redirecting HTTP -> HTTPS you should choose "Force SSL with https redirect" on a domain management page

poralix.png
 
As far as I know DirectAdmin under Account Manager > Site Redirection can redirect only http://example.com/anything to http://another-example.com/anything

For redirecting HTTP -> HTTPS you should choose "Force SSL with https redirect" on a domain management page

If you have an SSL certificate for the domain, you can also use the option in the SSL page to force a HTTPS redirect. I believe you'll get errors if you have a force redirect on and no certificate installed.

Pic taken from my production server and I use this as some of my software refuses to operate properly without HTTPS.


1759860912372.png
 
Back
Top