简体   繁体   English

Symfony2从外部服务器上的URL中删除Web

[英]Symfony2 remove web from the url on the external server

I've been looking for the solution for a long time. 我一直在寻找解决方案。 There are a lot of such topics and I know it. 有很多这样的话题,我知道。 But I still can't figure it out. 但我仍然无法弄清楚。 How can I remove web from the symfony2 project url? 如何从symfony2项目URL中删除web I tried to do this with htaccess looking like this: 我试图用htaccess来做到这一点,如下所示:

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^(.*)$ web/$1 [L]

but it doesn't work. 但这不起作用。 It gives me an error: 它给我一个错误:

 No route found for "GET /web/"

I really can't change the root directory on this server as only thing I have is FTP permission. 我真的不能更改此服务器上的根目录,因为我只有FTP权限。 Anybody has any idea for this? 有人对此有任何想法吗?

Edit: I also tried a trick to put all the files from web in root directory and the rest of the project higher. 编辑:我还尝试了一种技巧,将来自web所有文件放在根目录中,并将项目的其余部分放在更高的位置。 The problem is the highest directory I have access to is the root. 问题是我可以访问的最高目录是根目录。

You shall need to update your virtual host config file and set the DocumentRoot to point to the web folder. 您将需要更新虚拟主机配置文件,并将DocumentRoot设置为指向Web文件夹。

For example you may currently have it set as 例如,您当前可能将其设置为

DocumentRoot /var/www/myproject/    

but you need to update it to 但您需要将其更新为

DocumentRoot /var/www/myproject/web    

More information can be found within the Symfony2 cookbook here 更多信息,请参见Symfony2食谱

Also this shall stop anyone trying to access the config/parameters.yml 这也将阻止任何试图访问config / parameters.yml的人

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM