Symfony 2: How to remove the “/web/” folder from t

2020-07-26 16:20发布

问题:

I've been searching for a way to remove the "/web/" folder from an application URL in a shared environment, in which I cannot change the DocumentRoot or create a VirtualHost.

I found some solutions based on mod_rewrite, but all of them apply to Symfony 1.x, or they just don't work (I'm very new to mod_rewrite anyway, so it may be my fault).

Is there a way to do this with Symfony 2?

回答1:

You have to set web server's document root pointing to your "Web" directory. If you can't customize document root just move content of your "web" directory directly into document root and move all other staff one level above. For example:

/home/username/www/html <---- this is the place where you put all things from "web"
/home/username/www/src  <---- and all other things one level above
/home/username/www/app
/home/username/www/vendor
...