服务器 Gind.cn

服务器问题集锦,包括 Linux(Ubuntu, Centos,Debian等)和Windows Server服务器

Nginx重写目录到Symfony App,但删除主机目录

我有一个虚拟机,上面有几个开发应用程序。 基本的Web目录如下所示: /var/web/subdoms/: index.php MyApp/ SomeOtherApp/ 我有我的Nginx的configuration文件,指定根作为/ var / web / subdoms,例如: http://myserver/ -> /var/web/subdoms/index.php. 在MyApp子目录中,是一个Symfony2项目。 SomeOtherApp目录是一个通用的perl-cgi应用程序 http://myserver/SomeOtherApp -> /var/web/subdoms/SomeOtherApp/index.pl 对MyApp的请求需要redirect到以下子目录: http://myserver/MyApp/ -> /var/web/subdoms/MyApp/symfony/web/ 从那里,请求需要重写,以便请求被传递到'app.php'ala: http://myserver/MyApp/ -> /var/web/subdoms/MyApp/symfony/web/app.php http://myserver/MyApp/hello/you -> /var/web/subdoms/MyApp/symfony/web/app.php/hello/you 当我设置我的根:/ var / web / subdoms / MyApp / symfony / web /,并通过遵循symfony文档中的示例来请求sans'MyApp'时,我可以完成此操作。 然而,当我尝试嵌套应用程序的一个目录(以便我的服务器可以在同一个域上服务多个应用程序,而不是由symfony应用程序支配),“MyApp”部分被添加到URL ala: http://myserver.com/MyApp/hello/you -> /var/web/subdoms/MyApp/symfony/web/app.php/MyApp/hello/you 然后symfony抱怨说找不到路线“MyApp / hello / you”。 我可以通过在我所有的symfony路线上加上“MyApp”来解决这个问题,但是这让人感觉很笨拙。 […]