I recently needed to set up a Symfony install without a separate virtual host, so as a subdirectory of the (Apache) DocumentRoot directory (like: http://www.example.com/symfony/).
As you may know, symfony appreciates it when it has a reserved virtual host for itself, but also provides ways to just install it in a separate directory. The following steps need to be taken:
1. Change the apps/<yourapp>/config/settings.yml file and set relative_url_root
all:
.setttings:
relative_url_root: /subdir
2. Go to your front controller’s .htaccess file (usually in web/) and modify the RewriteBase directive
RewriteBase /subdir/
3. Optionally, if you want to omit the script name in production environment url’s, be sure to have enabled no_script_name = on in apps/<yourapp>/config/settings.yml
prod:
.settings:
no_script_name: on
4. If you took step 3, be sure to check if your apache installation has support for mod_rewrite enabled.
This way you can have nice url’s, like http://www.example/subdir/module/action
That’s it!
0 Responses to “Installing symfony in a subdirectory of your documentroot”