Symfony的2:如何删除" /网络/"从文件夹中的URL共享托管?文件、夹中、网络、Symfony

2023-09-02 11:25:52 作者:心癌晚期

我一直在寻找一种方式,从应用程序的URL删除/网络/文件夹,在共享的环境中,这是我无法改变的DocumentRoot或创建一个虚拟主机。

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.

我发现基于mod_rewrite的一些解决方案,但它们都适用于Symfony的1.x中,或者他们只是不工作(我很新反正mod_rewrite的,所以它可能是我的错)。

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).

有没有办法与Symfony的2做到这一点?

Is there a way to do this with Symfony 2?

推荐答案

您必须设置Web服务器的文档根目录指向您的网络目录。如果你不能自定义文档根只需将网络目录下的内容直接放入文档根目录并移动上述所有其他工作人员一个级别。例如:

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