Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have this configuration of virtualhost on my server. Everything works correctly except subdomain with www. When I go to URL with www I get the 404 error. I tried to solve this problem with mod rewrite but I did not know how to do it. Could someone help me? Thanks.

<VirtualHost *:80>
    ServerAdmin mail@localhost
    ServerName domain.com
    ServerAlias www.domain.com
    UseCanonicalName Off
    VirtualDocumentRoot /var/www/domain.com/www/
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin mail@localhost
    ServerName *.domain.com
    ServerAlias *.domain.com
    UseCanonicalName Off
    VirtualDocumentRoot /var/www/domain.com/sub/%-3+
</VirtualHost>
share|improve this question

migrated from stackoverflow.com Mar 3 '11 at 19:43

This question came from our site for professional and enthusiast programmers.

add comment

2 Answers

Try using DocumentRoot instead of VirtualDocumentRoot for www.domain.com?

share|improve this answer
    
I tried DocumentRoot but it still not working. –  user73062 Mar 4 '11 at 8:07
add comment

I don't think you can use wildcards on ServerName (as opposed to ServerAlias), perhaps that's causing problems somehow? Try ServerName domain.com on the wildcard virtual host.

Also, you should probably post the 404's in your error_log. The actual path reported missing may come handy to know how apache is resolving the request.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.