Quantcast
Viewing latest article 3
Browse Latest Browse All 10

Apache 2.4 subdomain setup fails

Image may be NSFW.
Clik here to view.
Question

I am struggling with this all the day, no answer i found here as well.
Please advice how to setup proper a subdomain i need.

My Apache config has 2 domains configured (on same IP), for the domain2.com i need to setup a sub-domain.
Here is what i have so far, but the subdomain keeps redirecting me to domain2.com (main site).

<VirtualHost 11.11.11.11:80>
ServerName domain1.com
ServerAlias domain1.com *.domain1.com
DocumentRoot "C:/wwwmap/domain1.com"
</VirtualHost><VirtualHost 11.11.11.11:80>
ServerName domain2.com
ServerAlias domain2.com *.domain2.com
DocumentRoot "C:/wwwmap/domain2.com"
</VirtualHost>        <VirtualHost 46.4.24.4:80>
        ServerName projects.domain2.com
        DocumentRoot "C:/wwwmap/projects"
        </VirtualHost>

The DNS entry is: projects in CNAME domain2.com

Trying to remove ServerAlias domain2.com *.domain2.com worked so far, but then domain2.com is redirecting to domain1.com

What am i doing wrong?

Asked by Grashopper

Image may be NSFW.
Clik here to view.
Answer

The projects.domain2.com vhost has to be defined before the vhost with with wildcard catch domain, than it will work.

<VirtualHost 11.11.11.11:80>
ServerName domain1.com
ServerAlias *.domain1.com
DocumentRoot "C:/wwwmap/domain1.com"
</VirtualHost><VirtualHost 11.11.11.11:80>
ServerName projects.domain2.com
DocumentRoot "C:/wwwmap/projects"
</VirtualHost><VirtualHost 11.11.11.11:80>
ServerName domain2.com
ServerAlias *.domain2.com
DocumentRoot "C:/wwwmap/domain2.com"
</VirtualHost> 
Answered by Grashopper

Viewing latest article 3
Browse Latest Browse All 10

Trending Articles