2

I manage a lot of projects on my personal development server. I just upgraded Apache and accidentally reset the configuration files in the process, so I thought this was a good opportunity to optimize my setup.

Before, I had one virtual host which pointed to a directory containing a bunch of project directories. That way I could just go to mydomain.com/MyProject. This works okay, but has some problems with certain kinds of linking.

I would vastly prefer to automatically map myProjectOne.mydomain.com to the myProjectOne directory. (I assume this behavior will always be case-insensitive because I'm using a subdomain instead of a directory name.)

I found this question that seems to be the answer. But when I used this approach, I got a 404 error.

<VirtualHost *:80>
  VirtualDocumentRoot /home/MyUsername/Projects/%0
  ServerName mydomain.com
  ServerAlias *.mydomain.com
</VirtualHost>

Also, I see a potential problem with this setup. My domain does point to my servers, and all the ports are configured correctly...however, I can't access that domain when I'm at home and on the same internal network as my servers.

Is there a setup that would do the same thing but would also allow me to utilize subdomain.localhost or subdomain.10.0.0.*?

What's the problem here?

Allenph
  • 135
  • 10
  • Three things to check- is UseCanonicalName Off? Add a trailing slash to the VirtualDocumentRoot path? And check on case sensitivity, my recollection is that case is normalized. – Jonah Benton Sep 02 '16 at 02:20
  • I have not configured `UseCanonicalName`. Let me try that. – Allenph Sep 02 '16 at 02:31
  • Just tried all the combinations of turning `UseCanonicalName` on and off on the virtual host, changing the case of the directory, and with and without the `/`. Still "The requested URL / was not found on this server." – Allenph Sep 02 '16 at 02:34
  • 1
    Ah, looks like this wants %1 rather than %0. The former renders just the subdomain, the latter renders the entire domain. Reference: http://docstore.mik.ua/orelly/weblinux2/apache/ch04_04.htm – Jonah Benton Sep 02 '16 at 02:43
  • *"however, I can't access that domain when I'm at home and on the same internal network as my servers."* that's probably because you have either a hosts file or made the [unfortunate design choice](http://serverfault.com/q/76715/37681) to name your AD domain after your registered domain name rather than using a subdomain of that domain name... – HBruijn Sep 02 '16 at 06:49
  • Check this answer which might help you: http://stackoverflow.com/a/18759855/272180 – yglodt Feb 07 '17 at 10:24

0 Answers0