I've lifted most of this from Wordpress, so any path on the domain like say /search
or /list
is directed to /index.php
. Fine that works.
However, it should not do that if the file being requested exists in the document root. So if I request /exists.php
it should run that script. Instead it's ignoring files on the filesystem and continues to serve index.php
.
<VirtualHost *:80>
DocumentRoot /home/sites/dev
ServerName dev.vbox
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . /index.php
ErrorLog /var/log/apache2/dev.error.log
</VirtualHost>
I've gone through the mod_rewrite documentation and various Google search results but I don't see anything wrong with my rewrite conditions. If the requested filename is a file or a directory, do not redirect to /index.php
.
I've cd
to the doc root and listed the contents of that directory, the file I'm requesting exists. My apache access log has entries for /exists.php
.
The document root is a mounted directory that lives on the my Mac and the VM serving the request is Ubuntu install.
Try
%{LA-U:REQUEST_FILENAME}
instead of%{REQUEST_FILENAME}
. The LA-U prefix is needed before the request is mapped to the filesystem.Edit:
Didn't catch it in my first pass, you also need to change the first argument to RewriteRule like so:
I ended up adding another rewrite condition, so my working Virtualhost looked like this: