DirectAdmin writes an Apache configuration for every domain from templates, and it rewrites those files whenever something changes. If you edit the generated files by hand, your change disappears at the next rewrite. This guide explains how DirectAdmin builds the Apache (HTTPD) configuration and the three safe places to put your own directives on a server you run yourself.
This is a server-administrator task: it needs DirectAdmin's admin level, so it applies to your own VPS or server running DirectAdmin, not to shared hosting. Put per-domain directives in Custom HTTPD Configurations, server-wide changes in a custom template copy or Apache's include file, then rewrite the configs and test with httpd -t. On Domain India shared DirectAdmin hosting you can't change the server's Apache configuration; use .htaccess instead.
1. Who this guide is for
Everything below needs root or DirectAdmin admin access. It applies to a VPS or dedicated server where you run DirectAdmin yourself. On Domain India shared DirectAdmin hosting, the Apache configuration is managed by us for every account on the server, and you make per-site changes in .htaccess, covered in section 8.
On your own server you are responsible for the Apache configuration. A bad directive can stop Apache for every site on the machine, so always test before you restart (section 6).
2. How DirectAdmin builds the Apache configuration
DirectAdmin never expects you to edit the per-domain Apache files directly. Instead:
- Templates in
/usr/local/directadmin/data/templates/describe what every virtual host looks like. The main ones arevirtual_host2.conf(HTTP) andvirtual_host2_secure.conf(HTTPS), with matching variants for subdomains. - Tokens such as
|DOMAIN|,|DOCROOT|and|USER|in those templates are filled in for each domain. - Generated files are written per user, usually to
/usr/local/directadmin/data/users/USERNAME/httpd.conf, and Apache includes them. - A rewrite regenerates all those files, for example when a domain is added, SSL is issued, the PHP mode changes or you run a rebuild.
That last point is why hand edits don't survive: the next rewrite replaces the file from the template.
The generated virtual host contains the directives you would expect:
<VirtualHost 203.0.113.10:80>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /home/username/domains/example.com/public_html
ErrorLog /var/log/httpd/domains/example.com.error.log
CustomLog /var/log/httpd/domains/example.com.log combined
</VirtualHost>The HTTPS version adds SSLEngine on and the certificate paths. DirectAdmin fills those in itself when it issues a Let's Encrypt certificate, so don't hard-code certificate paths.
3. Choose the right place for your change
| Scope of the change | Where it goes | Survives rewrites and updates |
|---|---|---|
| One domain | Admin level › Custom HTTPD Configurations | Yes |
| Every domain on the server | A copy of the template in templates/custom/ | Yes, but compare with new defaults after updates |
| Server-wide Apache settings | Apache's custom include file, or CustomBuild's custom/ folder | Yes |
| Any generated per-user httpd.conf | Nowhere: don't edit it | No |
4. Per-domain changes: Custom HTTPD Configurations
- Log in at admin level.Open DirectAdmin as the admin user.
- Open Custom HTTPD Configurations.It is in the server management area of the admin menu; type "Custom HTTPD" in DirectAdmin's search box if you can't see it.
- Pick the domain.DirectAdmin shows the full generated configuration for that domain, so you can see where your text will land.
- Choose the insertion point. Custom text goes into one of the `CUSTOM |
token positions in the template. The page's help text shows which token sits where in your DirectAdmin version, for example near the top of the virtual host, just before theDirectory` block, or at the end. - Add your directives and save.DirectAdmin checks the result and rewrites that domain's configuration.
Examples of what fits here:
# Allow symbolic links for this domain's document root
<Directory "|DOCROOT|">
Options +FollowSymLinks
</Directory># Compress text responses for this domain
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml application/javascript application/json image/svg+xml
</IfModule>Keep one purpose per block and add a comment, so the next administrator knows why it is there. Note that recent DirectAdmin versions offer settings for some common needs, such as forcing HTTPS or changing the PHP version, in the user panel; use those where they exist rather than custom directives.
5. Server-wide changes
For every virtual host: copy the template you want to change into the custom folder and edit the copy.
cd /usr/local/directadmin/data/templates
cp virtual_host2.conf custom/virtual_host2.confDirectAdmin uses the file in custom/ instead of the default. After a DirectAdmin update, compare your copy with the new default template, because new features sometimes need new lines in it.
For Apache itself (modules, timeouts, worker limits): don't edit the main httpd.conf, which CustomBuild can regenerate. Use Apache's extra include file (on most DirectAdmin servers /etc/httpd/conf/extra/httpd-includes.conf) or CustomBuild's custom/ folder, as described in DirectAdmin's documentation for your version.
Settings people usually tune here, with their current Apache 2.4 names:
KeepAliveandKeepAliveTimeout: reuse connections; keep the timeout short (a few seconds).MaxRequestWorkers: the maximum number of requests served at once. This replacedMaxClientsin Apache 2.4. Size it to your RAM.Timeout: how long Apache waits for slow clients and back ends.
6. Rewrite, test and restart
After any change, rebuild the configuration, check the syntax, then reload Apache.
# Rewrite all DirectAdmin-generated web server configs
da build rewrite_confs
# Check the syntax before reloading
httpd -t
# Reload Apache without dropping connections
systemctl reload httpdOn older DirectAdmin versions without the da command, run ./build rewrite_confs from /usr/local/directadmin/custombuild, or queue a rewrite with echo "action=rewrite&value=httpd" >> /usr/local/directadmin/data/task.queue. If httpd -t reports an error, fix it before reloading; a restart with a broken configuration takes every site offline.
If httpd -t does not print "Syntax OK", Apache will refuse to start. Undo your last change, run the rewrite again and re-test. Keep a copy of every file before you edit it.
7. Troubleshooting
- Apache won't start after a change. Run
httpd -tfor the file and line number, then check the Apache error log in/var/log/httpd/. - Your change disappeared. It was made in a generated file. Move it to Custom HTTPD Configurations or a custom template.
- Symbolic links give 403 Forbidden. Add
Options +FollowSymLinks(or the safer+SymLinksIfOwnerMatch) inside the correctDirectoryblock. - The site uses an old certificate. Let DirectAdmin manage SSL; custom SSL directives that hard-code certificate paths go stale when the certificate renews.
- Compression or headers don't appear. Confirm the module is loaded with
httpd -M, and check whether a proxy or CDN in front of Apache changes the response.
8. On Domain India shared DirectAdmin hosting
On shared hosting you don't need, and can't get, admin-level access. You make per-site web server changes in a .htaccess file in your site's folder. Measured on our DirectAdmin server in September 2026:
mod_rewriteis loaded and.htaccessis allowed, so redirects and rewrite rules work. See how to use mod_rewrite.- Only these
Optionsvalues are allowed in.htaccess: Indexes, IncludesNOEXEC, MultiViews, SymLinksIfOwnerMatch, FollowSymLinks and None. Any other value causes a 500 error. - PHP does not run as an Apache module, so
php_valueandphp_flaglines in.htaccesscause a 500 error. Change PHP settings in the panel instead. - Free Let's Encrypt SSL is managed from the panel; see Let's Encrypt SSL in DirectAdmin.
If you get a 500 error after an edit, restore your previous .htaccess and read troubleshooting 500 internal server errors.
If you need your own Apache configuration, a VPS gives you root access. Domain India VPS plans are self-managed, and the VPS page lists DirectAdmin as a paid panel option alongside the free choices.
- 1 vCPU
- 2 GB DDR4 RAM
- 64 GB NVMe SSD Storage
- 2 TB Monthly Bandwidth
For a site that only needs .htaccess rules, DirectAdmin shared hosting is simpler and cheaper:
- 10 GB NVMe SSD Storage
- 50 GB Monthly Bandwidth
- 1 Website
- 5 Email Accounts
Frequently asked questions
Can I use Custom HTTPD Configurations on DirectAdmin shared hosting?
No. Custom HTTPD Configurations is an admin-level tool, so it is available only on a server where you run DirectAdmin yourself, such as a VPS. On shared hosting, put your rules in a .htaccess file in your site's folder.
Why did my changes to httpd.conf disappear?
DirectAdmin regenerates each user's Apache configuration from templates whenever something changes, so edits to generated files are overwritten. Put per-domain directives in Custom HTTPD Configurations and server-wide changes in a custom template or Apache's include file.
How do I rebuild the Apache configuration in DirectAdmin?
Run da build rewrite_confs on current versions, or ./build rewrite_confs from the custombuild folder on older ones. Then check the syntax with httpd -t and reload Apache only if it reports Syntax OK.
What replaced MaxClients in Apache?
MaxRequestWorkers. Apache 2.4 renamed MaxClients to MaxRequestWorkers. Size it to the memory your server has, because each worker uses RAM.
Why does php_value in .htaccess give a 500 error?
The directive works only when PHP runs as an Apache module. On Domain India shared servers PHP runs through PHP-FPM or CGI, so Apache does not recognise php_value and returns a 500 error. Change PHP settings in your control panel instead.
Which Options can I use in .htaccess on Domain India DirectAdmin hosting?
Indexes, IncludesNOEXEC, MultiViews, SymLinksIfOwnerMatch, FollowSymLinks and None. Any other Options value in .htaccess causes a 500 error on our DirectAdmin servers.
Ready to take control of your server? Compare VPS plans for your own DirectAdmin server, or DirectAdmin hosting if .htaccess rules are all you need. For help, use our 24/7 live chat or open a ticket.
Full root access on a self-managed VPS, with a choice of Linux and control panel.
See VPS plans