I have this rewrite rule to direct request to my symfony 2 application:
RewriteCond %{REQUEST_URI} ^/foo/.*$
RewriteRule ^/foo(/.*)$ /srv/webapps/symfony2/web/app.php [QSA,L]
If I access http://test-server.com/foo/myController
I get a symfony exception telling me that it doesn't know how to route foo/myController
.
I don't want to add foo
to the route in symfony since the application has to work with other URL prefixes as well. How can I make sure that the foo
part is not visible by symfony?
As it appears that you are attempting to redirect requests made to a specific context path (
foo
) to a single file, perhaps you would find the following (modified from this apache documentation) useful: Alias /foo /srv/webapps/symfony2/web RewriteBase /fooEdit: Alternatively, you could amend your original solution to include the
PT
flag to pass the rewritten URI through to the application for processing, eg:(note that
L
is implied byPT
as noted in the documentationAfter all I got it working. My solution looks like this:
I don't know why this happens, but it seams to be important that alias and directory point directly to the symfony
web
folder. If they point to/srv/webapps/symfony2
and the final rewrite points toweb/app.php
you get the alias root prepended to the URI.