mod_rewrite not working

RhapX picture RhapX · Sep 19, 2010 · Viewed 36.1k times · Source

I'm new to server administration but I was able to get a LAMP setup running on my new VPS. I uploaded a few web files that work on my other server, but they seem to give me the error: "File does not exist" in my /var/log/apache2/error.log file. The homepage loads just fine through my scripting, but other pages don't.

.htaccess file code

    Options +FollowSymlinks
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?r=$1 [L,QSA]

I have enabled mod_rewrite on the server and can see it running under my phpinfo() page I have created. Simply don't know why this issue is happening. If I need to post anything else, please let me know :)

Answer

Álvaro González picture Álvaro González · Sep 19, 2010

It looks like your site or virtual host has not been granted the appropriate permissions to process .htaccess files. You can test it easily by making a syntax error on purpose: if your site does not crash, the file is being ignored.

Try something like this in your main httpd.conf file:

<Directory "/path/to/your/site">
    AllowOverride All
</Directory>

... or this (to your liking):

<VirtualHost *:80>
    AllowOverride All
</VirtualHost>