Wildcard and subdomain overules one another.

ros

Verified User
Joined
Jun 1, 2011
Messages
5
Hi,

I have a wildcard as subdomain to redirect all the unknown subdomains to my webroot.
This works perfectly. But the subdomains i want to redirect to my subdomain webroot also gets redirected to the main webroot.

I followed http://help.directadmin.com/item.php?id=127 but this does not work as expected.

How can i redirect the existing subdomains to there own webroot while also having a wildcard subdomain?

Centos 5.6/64 bit
Directadmin version=1.39.1
 
Then you have to move them above your other virtual host in your httpd.conf
 
Then you have to move them above your other virtual host in your httpd.conf

Yes, in the original configuration the *.subdomain alias was above the rest. I changed the position serveral times from top / middle / bottom and reloaded apache but had no effect.
 
Apache uses the first match. So start at the top of the httpd.conf file, and check it, and all the Include files (at the point at which they're included) and hopefully you'll find what it's matching.

Jeff
 
Hi, I had the same problem, wildcard and few subdomains with mail support (subdomains added as domains).

httpd.conf includes wildcard first and then subdomain, so subdomain doesn't work:
Code:
<VirtualHost 11.22.33.44:80 >

ServerAlias *.domain.tld

        ServerName www.domain.tld
        ServerAlias www.domain.tld domain.tld
			
     		[...]
			
</VirtualHost>

<VirtualHost 11.22.33.44:80 >

        ServerName www.sub.domain.tld
        ServerAlias www.sub.domain.tld sub.domain.tld
     
	  		[...]	

</VirtualHost>

You have to switch entries - put wildcard on bottom, subdomains at top

Code:
<VirtualHost 11.22.33.44:80 >

        ServerName www.sub.domain.tld
        ServerAlias www.sub.domain.tld sub.domain.tld
     
	  		[...]	

</VirtualHost>

<VirtualHost 11.22.33.44:80 >

ServerAlias *.domain.tld

        ServerName www.domain.tld
        ServerAlias www.domain.tld domain.tld
			
     		[...]
			
</VirtualHost>

Only problem is that if you change anything in directadmin (add, remove domain, subdomain, etc) httpd.conf file is rewritten. Any way to solve that?
 
Did you edit the httpd.conf from directadmin or by ssh?

You might be able to put some sort of if statement in the virtual host templates.
 
You should be able to chattr the user-level httpd.conf file immutable so it won't be changed.

Jeff
 
Did you edit the httpd.conf from directadmin or by ssh?

You might be able to put some sort of if statement in the virtual host templates.

From SSH, edited directly httpd.conf of one selected user. This have nothing to do host template.
 
You'd better use then SSH and httpd-includes.conf in order to plug your custom virtualhost settings, and no chattr will be required.
 
Use httpd-includes.conf for one particular domain? Could You describe it?
 
Describe what? Create your own file with Apache's directives in /etc/httpd/conf/extra/ and include it in httpd-includes.conf.
 
Back
Top