Mod rewrite does not work even if it is enabled

I've recently setup Apache/MySQL/PHP on my Debian Squeeze to test a few things and got confused with mod_rewrite. Even the module was properly enabled into PHP my application didn't work. I was always getting a 404 error. Apache logs showing nothing relevant.

After searching here and there I managed to solve the issue by simply editing the file /etc/apache2/sites-enabled/000-default like:

ServerAdmin webmaster@localhost

DocumentRoot /var/www

  Options FollowSymLinks
  AllowOverride All

  Options Indexes FollowSymLinks MultiViews
  AllowOverride All
  Order allow,deny
  allow from all

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

  AllowOverride All
  Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
  Order allow,deny
  Allow from all

ErrorLog ${APACHE_LOG_DIR}/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog ${APACHE_LOG_DIR}/access.log combined

    Alias /doc/ "/usr/share/doc/"
        Options Indexes MultiViews FollowSymLinks
        AllowOverride All
        Order deny,allow
        Deny from all
        Allow from ::1/128



What make the mod_rewrite to work is the directive AllowOverride None to be AllowOverride All.

Don't ask me more, ask Apache.... :)

Posted on: 24/02/2011

If you want to leave a comment please Login or Register