Apache on Mac: vhost looks for wrong directory (other than DocumentRoot)

0

I just un-installed XAMPP and decided to take into use the Apache included within OS X. After a lot of fiddling around I've gotten it to somewhat work, but not quite.

I use VirtualHostX for managing vhosts to my local projects. When I add a vhost (e.g. project.dev -> htdocs/Project) using the app, that vhost will work properly.

However, when I try to access localhost, things get weird. Let's say I navigate to localhost/foo on my browser. It gives 404, and this can be found in the error-logs:

[error] [client 127.0.0.1] File does not exist: /path/to/htdocs/Project/foo

So, basically it seems that the first vhost I have set up defines the folder where localhost/* tries to look for files.

Any ideas? It is very possible I've messed up some configuration by either using XAMPP or VirtualHostX.

Martti Laine

Posted 2013-06-08T11:00:34.520

Reputation: 211

Answers

0

You also need to set the main document root in the http.conf file. Otherwise Apache will use the first vhost avaible.

DaGardner

Posted 2013-06-08T11:00:34.520

Reputation: 103

It is set to the appropriate path: DocumentRoot "/same/path/to/htdocs". Also the appropriate <Directory>-tag is edited properly. – Martti Laine – 2013-06-08T11:04:26.303

Maybe post a (censored) version of your conf file. – DaGardner – 2013-06-08T11:05:49.660

What portions do you think would be most useful? The whole file is pretty long. I can copy the parts that would help. – Martti Laine – 2013-06-08T12:19:26.567

Where you define the vhost and document root, – DaGardner – 2013-06-08T16:27:07.043

0

You need to set up a localhost vhost. Once you enable virtual hosting, Apache uses the first vhost if no vhost match, as outlined in the documentation: http://httpd.apache.org/docs/current/en/vhosts/name-based.html.

user2313067

Posted 2013-06-08T11:00:34.520

Reputation: 2 160

I've tried using VirtualHostX to set a vhost like this: localhost -> /path/to/htdocs, but I get error 403 Forbidden. Here's an example of the lines that show up in logs (when requesting localhost/foo): [error] [client ::1] mod_hfs_apple: Mis-cased URI: /path/to/htdocs/foo, wants: /path/to/htdocs/ – Martti Laine – 2013-06-08T18:24:35.853