Our features site is undergoing a refresh! Be sure to explore the revamped site and discover our latest product roadmap launching here on Monday, March 18th.

Always insert SubDomains before the main domain when generating httpd.conf

Frans Bouwmeester shared this idea 9 years ago
Open Discussion

In httpd.conf, VirtualHost entries for SubDomains are (random?) listed after the main domain entry.

This prevents subdomains from being served when the main domain includes a wildcard ServerAlias.

For example in the below, blog.mydomain.com would not be served.

Putting the blog.mydomain.com entry before the mydomain.com entry would solve the issue.

<VirtualHost 1.2.3.4:80>

ServerName mydomain.com

ServerAlias *.mydomain.com http://www.mydomain.com

DocumentRoot /home/mydomain/public_html

....

</VirtualHost>

<VirtualHost 1.2.3.4:80>

ServerName blog.mydomain.com

ServerAlias http://www.blog.mydomain.com

DocumentRoot /home/mydomain/public_html/blog

....

</VirtualHost>

Leave a Comment
 
Attach a file