This is quiet similar to my question Symfony on virtual host (document root problem).
This is my .htaccess
in the project root directory:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/images/ [OR]
RewriteCond %{REQUEST_URI} ^/js/ [OR]
RewriteCond %{REQUEST_URI} ^/css/
RewriteRule ^(.*)$ /web/$1 [L]
RewriteCond %{REQUEST_URI} !^/web/
RewriteRule ^(.*)$ /web/index.php [QSA,L]
This solved my problem but symfony tries to generate every url (eg. using url_for
) from the document root so instead of url like domain.com/my-article
it generates domain.com/web/my-article
.
I had to slightly modify my PatternRouting
class to trim the /web
prefix from each url. I think this is not the best solution but it works.
Also if I want to access backend application I have to call always /web/backend.php/
because I don't want to have so many rewrite rules in the .htaccess
.
If you want to see my extended PatternRouting
class source code I'll paste it here.