The php Symfony framework comes with url rewritting management (allowing you for example to have url such as mysite.com/article/how-to-enable-mod_rewrite/ instead of mysite.com/article?id=124523).
On deploying the application on the production server however this was not working, I was getting 404 errors – after a little search on Symfony doc I found out that
a) the apache module mod_rewrite needed to be enabled
b) symfony configures the mod_rewrite for the application on a .htaccess file, which, depending on your server configuration, may not be read by the server.
On Debian, a) is quite simple: the module is actually available by default when installing apache, you just need to enable it, by moving the loading file from the /mods-available folder to the /mods-enabled folder:
mv /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/
[UPDATE] as suggest Ludovic, the following command is probably better:
a2enmod rewrite
[UPDATE2] Indeed the a2enmod command must be used instead of the former move command – as a2enmod actually create a symlink and don t move the file.
and then reload apache:
/etc/init.d/apache2 reload
Regarding b), we need to ensure that AllowOverride is set to All in the Alias or VirtualHost directory:
<Directory /my/web/root/directory/> ... AllowOverride All ... </Directory>
