0

I'm having a weird redirect problem on my local server. I have a VirtualHost set up:

NameVirtualHost *:80

<VirtualHost *:80>
    DocumentRoot "/Users/iMac/Sites/index.php"
    ServerName jordan.local
    ErrorLog "/private/var/log/apache2/jordan.local-error_log"
    CustomLog "/private/var/log/apache2/jordan.local-access_log" common  
    <Directory "/Users/iMac/Sites/index.php">
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

Accessing http://jordan.local works fine. However, when I attempt to access a subdirectory jordan.local/somefolder/index.php, the page shown is jordan.local/index.php. I do not have an .htaccess file and have restarted apache numerous times.

Apache version: 2.2.22 (Unix)
Mac OS X 10.7.5

Here's my host file if it's any help:

127.0.0.1       localhost
255.255.255.255 broadcasthost
::1             localhost
fe80::1%lo0     localhost
#74.208.10.249 gs.apple.com
127.0.0.1       jordan.local

All of the local URL's I accessed (that are non-existent) showed up in my custom access logs as a 200 response code.

My Apache error logs are giving this warning:
Warning: DocumentRoot [/Users/iMac/Sites/index.php] does not exist
Although /Users/iMac/Sites/index.php is a valid path.

Please let me know if you need any more information.

0

1 Answer 1

1

Please change DocumentRoot to point to a directory, not a file. Reference: http://httpd.apache.org/docs/2.2/mod/core.html#documentroot

DocumentRoot

DirectiveDescription: Directory that forms the main document tree visible from the web

Syntax: DocumentRoot directory-path

Default: DocumentRoot /usr/local/apache/htdocs

Context: server config, virtual host

Status: Core

Module: core

This directive sets the directory from which httpd will serve files. Unless matched by a directive like Alias, the server appends the path from the requested URL to the document root to make the path to the document.

Example:

 DocumentRoot /usr/web 

then an access to http://www.my.host.com/index.html refers to /usr/web/index.html. If the directory-path is not absolute then it is assumed to be relative to the ServerRoot.

The DocumentRoot should be specified without a trailing slash.

0

Not the answer you're looking for? Browse other questions tagged .