问题描述
我要访问的生产ENV我的symfony应用程序( http://www.sample.com/amateur1/从网络这个网址 http://www.sample.com/amateur1 / app.php )。
I want to access my symfony app in production env (http://www.sample.com/amateur1/web/app.php) from this url http://www.sample.com/amateur1.
要做到这一点,我搬到了.htacces文件,以 http://www.sample.com/amateur1/.htaccess一>与此内容:
To do that I moved the .htacces file to http://www.sample.com/amateur1/.htaccess with this contents:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /web/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app.php [QSA,L]
</IfModule>
但是,当我去 http://www.sample.com/amateur1 显示404错误,而 prod.log 的未写
But when I go to http://www.sample.com/amateur1 shows a 404 Error, and prod.log isn't written.
我还用的RewriteBase / amateur1 /网络/
,因为我不知道的的RewriteBase 的路径是相对的的DocumentRoot 的服务器,或者从其中的的.htaccess 的文件所在的路径。也试过 / amateur1
和 / amateur1 /
作为的RewriteBase由于这个答案Symfony2:如何部署的子目录(阿帕奇)
I also used RewriteBase /amateur1/web/
because I don't know If RewriteBase path is relative to the DocumentRoot of the server, Or from the path where the .htaccess file is located. Also tried /amateur1
and /amateur1/
as RewriteBase due to this answer Symfony2: How to deploy in subdirectory (Apache)
通过三试的,异常的页面看起来无样式,并且不加载任何图像。但后来我收到以下错误prod.log文件:
With the three try's, The Exceptions page appears unstyled, and not loading any image. But then I get the following error in prod.log file:
[2013-02-15 02:06:47] request.ERROR: Symfony\Component\HttpKernel\Exception\NotFoundHttpException: No route found for "GET /amateur1/" (uncaught exception) at /home/u105859802/public_html/amateur1/app/cache/prod/classes.php line 5121 [] []
我在做什么错了?
What I'm doing wrong ?
推荐答案
在您的配置,Apache使用的的public_html
作为文档根目录
In your configuration, apache uses public_html
as the document root
如果Symfony2的安装目录 /主页/ u105859802 /的public_html / amateur1
,服务Symfony的公共目录是 /主页/ u105859802 /的public_html / amateur1 /网络/
If Symfony2 is installed in directory /home/u105859802/public_html/amateur1
, the Symfony public directory to serve is /home/u105859802/public_html/amateur1/web/
您应该使用
RewriteBase /amateur1/web/
但要注意,这不是安全的
您必须保护你的symfony目录! (配置访问)
你为什么不尝试移动你的symfony文件在你的私人空间?
您可以重命名Symfony的网页目录的public_html
Why don't you try moving your symfony files in your private area ?
You can rename the Symfony web directory to public_html
请参阅how要做到这一点的文件食谱
所以,我的建议结构看起来象下面这样:
So, my recommendation structure looks like below :
- /主页/ u105859802 /
- 厂商
- 的src
- 应用
- 箱
- 的public_html (默认在Symfony2中网)的&LT; - 唯一的公共目录
- /home/u105859802/
- vendor
- src
- app
- bin
- public_html (web by default in symfony2) <- the only public directory
这篇关于如何在共享主机部署Symfony2的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!