I'm developing an application in Symfony and on localhost (XAMPP) I want to simulate the same conditions as on the webserver.
The web server is configured as follows:
/www => mydomain.com
/foo => foo.mydomain.com
/bar => bar.mydomain.com
...
I'm going to put my Symfony application into /www
direcotry so there'll be:
/www
/www/apps
/www/apps/frontend
/www/apps/frontend/...
/www/apps/backend
/www/apps/backend/...
/www/cache
/www/config
... and so on...
/www/web
The thing is that the document root is still set to the /www
directory but Symfony expects it in the /www/web
.
Of course it will work if I call http://mydomain.com/web
but I guess you understand this is quiet stupid solution.
So my question is: Is there any way how can I change/bypass the default document root setting using .htaccess or whatever?
EDIT: I solved it.
I you got hand on apache config, the better is to move document root from
/www
to/www/web
in you virtualHost config and allow php (if restricted byopen_basedir
configuration directive) to access the whole/www
directory.Change the way symfony expects your directory to be named :
I don't know much about Symfony but
/web
is supposed to be the document root. All the other directories should be outside the document root for security reasons for one, and to avoid the/web
part in the URL for another. But it looks like you already know that.If you can edit the web server's configuration, try to reflect that and set
DocumentRoot
to the web directory.If you can't do that: It's not possible to change the
DocumentRoot
in a.htaccess
file but it is possible to rewrite all requests so they go to/web
internally usingmod_rewrite
. It's kludgy, but probably the best solution if you can't influenceDocumentRoot
.I'm not a mod_rewrite guru so I can't provide an example (I would have to test it first and I can't do that right now) but I'm sure somebody will. Maybe add the
mod_rewrite
tag to your question.Update: Untested but should work. Put into a
.htaccess
file in/www
:you would then need to change your configuration files to use
http://www.domain.com/
instead ofhttp://www.domain.com/web/
of course.I can't say whether that interferes with any other
.htaccess
rules on the Symfony end - you'd have to try out.