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