问题描述
在子目录或别名中部署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)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!