本文介绍了Symfony2:如何在子目录中部署(Apache)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

在子目录或别名中部署symfony2应用程序的最佳方法是什么?

What is the best way to deploy symfony2 application in a subdirectory or an alias ?

让我们说我的应用程序将在以下环境下运行:http://domain/symfonytest

Lets say that my application will run under: http://domain/symfonytest

symfonytest是文件系统中某个目录的别名.

symfonytest is an alias to some directory in my filesystem.

我可以使用一些CLI操作吗?

Is there some CLI operation that I can use ?

当我尝试手动配置它时,我发现路由出现问题.

When I try to configure it manually I see a problem with routing.

http://domain/symfonytest/demo的记录被路由器视为/symfonytest/demo

Requets to http://domain/symfonytest/demo are seen by router as /symfonytest/demo

有没有办法告诉路由器忽略整个应用程序的/symfonytest前缀?

Is there a way to tell router to ignore /symfonytest prefix for the whole application ?

推荐答案

如果您使用的是Symfony< 2.3您可以采用这种方法:

If you are using Symfony < 2.3 you could follow this approach:

只需在您的.htaccess文件中添加 RewriteBase :

Just add RewriteBase in your .htaccess:

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

这篇关于Symfony2:如何在子目录中部署(Apache)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-07 18:29