I'm currently working on a Symfony2 application that, for the time being, has to be hosted inside a subdirectory. Normally one would change the DocumentRoot in the Apache vhost but this is currently not possible. It's also not possible to place anything in the root directory (e.g. above public_html/
).
The DocumentRoot is set at /public_html/
. The structure with the Symfony2 app in a subdirectory looks like this:
- public_html/
-- dev/
---- app/
---- bin/
---- src/
---- vendor/
---- web/
Without any special configuration the app can be reached at http://example.com/dev/web/app.php. I however want to change this to http://example.com/dev without having to move files around.
I came up with the following .htaccess
:
RewriteEngine on
RewriteCond %{REQUEST_URI} !dev/web/
RewriteRule (.*) /dev/web/app.php/$1 [L]
This kinda works, but Symfony2 reports the following error: No route found for "GET /dev/"
.
If I change the RewriteRule to RewriteRule (.*) /dev/web/$1 [L]
I can reach the app with http://example.com/dev/app.php/dashboard (dashboard being an example of course) which results in No route found for "GET hboard"
, notice hboard. Calling http://example.com/dev/app.php/ does render the page at / perfectly and links to all assets work fine as well.
Any help would be much appreciated. In time this app has to move from dev/
to /
as well. So a solution for that is welcome as well.