I’m using Symfony2 on a shared server, and I’ve been trying to fix an issue I’m having. I want to get rid of the app.php landing page, and at the same time point to symfony’s web directory as the root directory.
So getting the root directory set up is easy.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !^/symfony/web/
RewriteRule ^(.*)$ /symfony/web/$1
</IfModule>
I’m stuck after this though. I tried
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !^/symfony/web/
RewriteRule ^(.*)$ /symfony/web/$1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ $1app.php [L]
</IfModule>
Thinking that this would run sequentially. However, it doesn’t. Instead, it seems to look for both conditions, and then run both rules at the same time. For example, if I call example.com/app.php it will fetch example.com/symfony/web/app.phpapp.php . I’ve tried various combinations of various tags, and I’ve concluded that they simply always run at once, contrary to what I’ve read on the internet. The official doc is really sparse with examples, and doesn’t answer the problem I have.
Anyone have any ideas where I’m going wrong?
Thanks.
The following hid the need for app.php and pointed everything towards the right public folder. One thing to note, all public resources in symfony is stored in /web/bundles, while the only thing accessed in the web directly by a user is actually app.php.
It first looks for whether it’s /bundles, and then prepends symfony/web to it and stops there. Otherwise, it looks for whether /symfony/web is there and if not, prepends app.php to it and stops. Since I use symfony to generate all my urls in my php code, this doesn’t pose a problem.
Preferably, it would see prepend symfony/web to everything, then test if it was a file, and if it wasn’t, it would add app.php to the end. Unfortunately, I couldn’t get it to work. Symfony does its own redirections when it detects a page doesn’t exist, and being inside a vhost just added more complexity, so this is as good as I can get it.