0

I have mod_vhost_alias enabled. My GoDaddy DNS A-Record Host='*' points to my server.

In /etc/apache2/sites-available/000-default I have

<VirtualHost *:80>
    UseCanonicalName Off
    VirtualDocumentRoot /var/www/%0/public_html
    VirtualScriptAlias /var/www/%0/cgi-bin
</VirtualHost>

But when I try to go to subdomain.domain.com I get:

Not Found

The requested URL / was not found on this server. Been working at this ALL day! PLEASE help! Thank you!

UPDATE: So I got this to work by changing the %0 to %1 because my folder names were "subdomain" however now if I go to domain.com instead of subdomain.domain.com I get an error... How can I have the best of both worlds?

jjNford
  • 103
  • 3

2 Answers2

1

Here's the deal: Fix the C:/'s in my example and update the paths for yours.

Make sure you have the "NameVirtualHost" at the top of the vHosts section.

<VirtualHost *:80>
    ServerAdmin support@u4ik.us
    DocumentRoot "C:/xampp/htdocs/"
    ServerName u4ik.info
    ServerAlias www.u4ik.info
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin support@u4ik.us
    DocumentRoot "C:/xampp/url/"
    ServerName 2.u4ik.us
    ServerAlias 2.u4ik.us
</VirtualHost>
U4iK_HaZe
  • 631
  • 5
  • 13
0

I think for simplicity sake, you need to choose one or the other. If you going go with the Virtualhost, follow the example that U4iK_HaZe provided, like so:

<VirtualHost *:80>
    ServerAdmin support@yourdomain.com
    DocumentRoot /yourpath/to/yoursite/
    ServerName yourdomain.com
    ServerAlias www.yourdomain.com
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin support@subdomain.yourdomain.com
    DocumentRoot /yourpath/to/yoursitesubdomain/
    ServerName subdomain.yourdomain.com
    ServerAlias www.subdomain.yourdomain.com
</VirtualHost>

If you are going to use VirtualDocumentRoot, you go with this:

UseCanonicalName Off
VirtualDocumentRoot /yourpath/%0/htdocs

I think, though, that you know that part. What I am not sure is whether you created the appropriate directories on the server. %0 matches the whole domain, so on the server, if you need to bring up subdomain1.yourdomain.com, the directory path should be:

/yourpath/subdomain1.yourdomain.com/htdocs

For subdomain2.yourdomain.com:

/yourpath/subdomain2.yourdomain.com/htdocs

However, since it seems that you don't have much experience in pattern matching, I strongly suggest going with the VirtualHost Option and leave VirtualDocumentRoot alone for the time being.

Rilindo
  • 5,058
  • 5
  • 26
  • 46