有没有办法在没有将'web'目录的内容移动到root的情况下从Symfony应用程序中的url中删除'/ web'?

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 ?

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.

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">
# ...

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]

You can create a .htaccess into project root folder(where is the folder like app, bin, src...):

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ /web/$1 [QSA,L]
</IfModule>

I think you guys are sweating it.

Correct me if I am wrong, but I managed to remove it by simply putting everything in the web directory inside the root directory. Then I eliminated app_dev.php, and renamed app.php into index.php.