我已经接近让Symfony2运行GoDaddy共享主机方案(包含多个网站)。
所以我可以通过web / ftp访问以下内容(注意,上面有另一个目录级别,我可以通过SSH访问):
/ <-- dummy domain points here to "hide" it sort of
----/SiteA <-- sitea.com (Wordpress, working fine)
----/SiteB <-- siteb.com (Wordpress, working fine)
----/SiteC <-- sitec.com (Wordpress, working fine)
----/Symfony
--------/app
--------/web <-- symfonysite.com
------------/.htaccess
------------/app.php
我可以在symfonysite.com
访问默认控制器就好了。但是当我点击一个链接(例如symfonysite.com/my/page
)时,我得到一个500错误。
当我尝试去symfonysite.com/app.php
时,它甚至更奇怪了。我最终在symfonysite.com/Symfony/web
。
显然,.htaccess
中的某些内容不对,因为它没有正确重写。不知何故,它与Web根相关,而不是与特定停放域的根相关。我猜这是一个简单的修复,但我没有.htaccess的经验(这只是2.3的默认设置)。这是在下面,删除了评论:
DirectoryIndex app.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^app\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .? - [L]
RewriteRule .? %{ENV:BASE}/app.php [L]
</IfModule>
<IfModule !mod_rewrite.c>
<IfModule mod_alias.c>
RedirectMatch 302 ^/$ /app.php/
</IfModule>
</IfModule>
答案 0 :(得分:2)
在我发帖时,我通过更仔细地阅读.htaccess
中的评论来找出答案。发布此Q&amp; A以防其他人。
问题在于:
# Determine the RewriteBase automatically and set it as environment variable.
# If you are using Apache aliases to do mass virtual hosting or installed the
# project in a subdirectory, the base path will be prepended to allow proper
# resolution of the app.php file and to redirect to the correct URI. It will
# work in environments without path prefix as well, providing a safe, one-size
# fits all solution. But as you do not need it in this case, you can comment
# the following 2 lines to eliminate the overhead.
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
我认为这会改变我的重写为/Symfony/web/app.php而不是/app.php。评论这些线是有效的。