Actual Subdomains and Wildcard Subdomains

Fatty

Verified User
Joined
Aug 3, 2011
Messages
9
So I'm working in DA, and attempting to add a wildcard subdomain in order to direct all non-existent subdomains to the webroot of the main domain. This is simple by adding a wildcard ServerAlias. However, in my case, I have an actual subdomain which has it's own docroot defined. As of right now, the contents of the httpd.conf file for domain.tld looks like this:

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>

The only problem is that, since the wildcard ServerAlias was added to the main domain, the actual subdomain does not get reached. I need to switch these around so that all VirtualHost contents for existing subdomains is printer BEFORE domains. I'm just not sure how to go about doing that, so any help would be greatly appreciated.
 
I actually already had something very similar to that using .htaccess. Here's the code in my .htaccess file:

Code:
RewriteCond %{HTTP_HOST} ^sub\.domain\.tld
RewriteRule ^(.*)$ /sub/$1 [L]

I set this up as a workaround until I found a full fix. But now that I see you're doing the same exact thing without the .htaccess file, I have one question. Does apache serve the contents faster when using the custom httpd config as you did in your post in comparison with doing it with .htaccess?
 
Back
Top