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'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.

share|improve this question

closed as off-topic by Shane Madden, mdpc, Scott Pack, Ward, Jenny D Jul 22 '13 at 9:00

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions about hardware or software used in a home setting are off-topic because they require answers that may not be practical for the business and support professionals here. You should try asking on Super User instead." – Shane Madden, mdpc, Scott Pack, Ward, Jenny D
If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer 1

up vote 0 down vote accepted

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.

share|improve this answer
    
Perfect! Thanks!! –  Jordan Jul 22 '13 at 0:16

Not the answer you're looking for? Browse other questions tagged or ask your own question.