subdomain (with changed docroot) still uses main domain config

vancanneyt

Verified User
Joined
Dec 13, 2012
Messages
92
Hi,

I made a subdomain for a domain in the GUI of DirectAdmin and changed the docroot in the GUI to a subdirectory. Normally this would be working as intended but for whatever reason when I browse to the subdomain, it still gives me my main domains content instead of what should be displayed from the changed document root.

When look at Nginx config I don't see any strange issues. The subdomain is there in the Nginx config but just doesn't seem to work at all. It even uses rewrite rules that are only defined in the main site (the rules of the main site vs subdomain where edited in the CUSTOM3 with |*if !SUB| |*endif| and |*if SUB="subdomain"| |*endif|). So it seems the Nginx config is broke in some way that it doesn't use the server block of the subdomain.

Simplified Nginx config:
Code:
server {
 server_name domain.com www.domain.com
 root /home/user/domains/domain.com/public_html;
     #a rewrite rule for the main domain
    location /l/ {
        try_files $uri $uri/ /l/index.php?$args;
    }
}
server {
 server_name subdomain.domain.com www.subdomain.domain.com
 root /home/user/domains/domain.com/public_html/subdirectory;
     #no rewrite rules
}

expected behavior:
subdomain.domain.com should bring me to the subdirectory

current behavior:
subdomain.domain.com brings me to the document roots content
rules for domain.com can be used on subdomain.domain.com although the Nginx config doesn't have it in its server block.

Edit: figured it out :)
 
Last edited:
Back
Top