How To: Change DocumentRoot Only For One Subdomain

  Domain Name

Ticket Example : IKW-712-91567

Same goes to the previous article “How To: Set Public Path”, however, going into more detail, the DocumentRoot for a subdomain will always have the “sub” name appended to the end. If this is not the desired effect, then the templates would have to be modified to get rid of the bit on the end, while still allowing subdomain paths for normal subdomains to be valid. To do that, first copy the templates to the custom folder


cd /usr/local/directadmin/data/templates/custom

Edit the two files below:

1. virtual_host2_sub.conf
2. virtual_host2_secure_sub.conf

For both conf. file edit


|?DOCROOT=`HOME`/domains/`DOMAIN`/public_html|

to


|?DOCROOT=`HOME`/domains/`DOMAIN`/public_html/`SUB`|

Same thing for this line:


|?CGI=ScriptAlias /cgi-bin/ `DOCROOT`/`SUB`/cgi-bin/|

change it to be:

|?CGI=ScriptAlias /cgi-bin/ `DOCROOT`/cgi-bin/|

and lastly


DocumentRoot |DOCROOT|/|SUB|

to

DocumentRoot |DOCROOT|

Save the 2 virtual_host2*_sub.conf with these 3 changes and the path will be what you’re looking for. All existing subdomains will also remain unaffected, since we just moved the SUB part from the bottom, and moved it to the top.