I have a virtual host running on my local copy of Apache. It has an alias.
<VirtualHost 127.0.0.1> ServerName oliverash.me.dev DocumentRoot "/usr/docs/oliverash.me/public" Alias /mayor "/usr/docs/uni/tmosct/public" </VirtualHost>
This works fine. I can access the alias by going to
oliverash.me.dev/mayor in my browser. However, I have a simple
.htaccess rewrite in that alias' folder, which rewrites everything (except folders) to the index.php page. This rewrite is working fine.
Although the rewrite is working, the rewrite returns with a 404 Not Found error. For instance, if I go to
oliverash.me.dev/mayor/abcdefg, that rewrites to the
index.php file, but I get this error:
"The requested URL /usr/docs/uni/tmosct/public/index.php was not found on this server."
This file does actually exist. I can access it directly.
When I use the same alias but for
localhost instead of just this virtual host, the rewrite works fine, and the index.php returns with the actual file, and not the 404. This makes me think it is something to do with the permissions of my virtual host. So I tried to add this beneath my
httpd-vhosts.conf (with no luck):
<Directory "/usr/docs/oliverash.me/public"> AllowOverride All Order allow,deny Allow from all </Directory>
These are the same settings that are used on the
DocumentRoot, so I don't see why it's not helping.
So I checked the Apache error_log. Turns out that the rewrites for this alias are actually relative to the document root of this virtual host.
[Fri Jan 06 22:30:57 2012] [error] [client 127.0.0.1] File does not exist: /usr/docs/oliverash.me.dev/usr
This rewrite is actually looking in
/usr/docs/oliverash.me.dev/public/usr/docs/uni/tmosct/public for index.php. Hopefully it is obvious that it should be looking in
Okay, this is a problem I'm experiencing a local copy of Apache. However, I've just run into exactly the same problem for an alias on my live Web server. This isn't using any kind of virtual host.
[Sat Jan 07 02:41:51 2012] [error] [client 126.96.36.199] File does not exist: /var/www/html/var
Again, the path is relative to the DocumentRoot. It should be an absolute path.
Kinda annoying :(
This is exactly the problem I am having, but perhaps much better phrased: http://forums.devshed.com/apache-development-15/rewritebase-alias-and-rewriterule-are-not-rooting-to-required-file-395917.html