Troubleshooting /sf directory with mod-rewrite on Symfony projects

Posted on Category:Symfony

This post shows example for setting up /sf directory required for default css and javascript files on Symfony projects. Symfony documentation describes how to create Alias for /sf directory, and on most configurations it works perfectly. Directory and all assets are visible, and usable by your web application.
However, if you still can’t get /sf assets to work, try creating a symbolic link in your web directory:
[php]
/your_project_dir/web: $ ln -s ../lib/vendor/symfony/data/web/sf sf
[/php]
Now try to access some files from the directory. If you still get an 404 message, try creating an .htaccess file in /sf directory and disable mod-rewrite engine for this directory:
[php]
# /your_project_dir/web/sf/.htaccess
RewriteEngine Off
[/php]