23

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 :)

RhapX
  • 1,663
  • 2
  • 10
  • 17

3 Answers3

50

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>
Álvaro González
  • 142,137
  • 41
  • 261
  • 360
  • 2
    Thanks for the comment. Where can I find my main httpd.conf file? – RhapX Sep 19 '10 at 18:40
  • 2
    In my situation, I needed to add `AllowOverride all` to `apache.conf` under ``. – bozdoz Jul 22 '14 at 08:30
  • I had different issue. mod_rewrite wasn't enabled for my apache. Just to help someone who might be looking a solution. Take a look at this link http://xmodulo.com/how-to-enable-mod_rewrite-in-apache2-on-debian-ubuntu.html – Humayun Mar 22 '16 at 18:32
  • When a given a module is not installed or enabled you get a clear message in your error log: *Invalid command 'Foo', perhaps misspelled or defined by a module not included in the server configuration* – Álvaro González Mar 23 '16 at 08:05
  • Where is the httpd.conf file? – Black Oct 19 '18 at 09:20
11

When I had this problem it turned out that the /etc/apache2/sites-enabled/000-default had the AllowOverride All, but the /etc/apache2/apache2.conf also had the same entry for our web Directory with AllowOverwrite None. So be sure to check both places!

Nathaniel Ford
  • 20,545
  • 20
  • 91
  • 102
Richard Keene
  • 398
  • 3
  • 14
0

ERROR: Module rewrite does not exist February 21, 2014 by Sharad Chhetri Leave a Comment

While working on Apache Module in Ubuntu,I found rewrite problem in Apache Web Server.I tried to enable the rewrite module but got this error ERROR: Module rewrite does not exist!.After troubleshooting,I found the problem was with mod_rewrite module.

After doing some more troubleshooting,it is found that the rewrite.load file was missing in /etc/apache2/mods-available/ .

Now,I checked the mod_rewrite.so actual module file and Wow it was there.

Below given is step by step command which I ran,to solve this issue.Here is the reference from my system

root@tuxworld:~# a2enmod rewrite

ERROR: Module rewrite does not exist!

root@tuxworld:~# ls -l /usr/lib/apache2/modules/mod_rewrite.so

-rw-r--r-- 1 root root 58728 May 28 2020 /usr/lib/apache2/modules/mod_rewrite.so

root@tuxworld:~#

root@tuxworld:~# echo "LoadModule rewrite_module

/usr/lib/apache2/modules/mod_rewrite.so" > /etc/apache2/mods-available/rewrite.load

root@tuxworld:~#

root@tuxworld:~# a2enmod rewriteEnabling module rewrite.

To activate the new configuration, you need to run:

service apache2 restart

root@tuxworld:~#

After this I restarted the apache2 service

sudo service apache2 restart

anas shah
  • 41
  • 5