I am facing a problem while creating applications using Symfony which is the occurrence of '/web' in the url. I found a way to get rid of this by moving the content of 'web' directory to root directory. But I think that is not a good development practice and there must be some other way. Can anyone let me know if there is some other way of doing this some thing like we do for removing app_dev.php from url using htaccess ?
5 Answers
In my case im working with wamp server and to get rid of "/web" you need to configure a virtual host in httpd-vhosts.conf like this :
<VirtualHost *:80>
DocumentRoot C:\wamp\www\YourProjectFolder\web
ServerName projectName.local
</VirtualHost>
I think you shoold do the same in your host server.
Comments
If you don't have the possibility to edit http.conf and mod_rewrite is enabled, simply place a .htaccess file in your Document root and redirect every request to the /web folder.
RewriteEngine on
RewriteRule ^(.*)$ /web/$1 [L,QSA]
1 Comment
Shairyar
This is how I am doing it. In shared hosting this seems to be the only solution
Do not move /web folder from Symfony. You just need point your vhost or Apache default root into your web directory. For example :
You can changing in httpd.conf :
# ...
DocumentRoot "your_symfony_folder/web"
<Directory "your_symfony_folder/web">
# ...
2 Comments
ggioffreda
Or if you are using Nginx: server { root your_symfony_folder/web; }
Jun Rikson
Yes, depends to his Apache Server.