除非删除web文件夹中的.htaccess文件,否则Symfony2无法访问app_dev.php

时间:2014-07-04 06:39:38

标签: php .htaccess symfony

Symfony2无法访问app_dev.php,除非在web文件夹中删除.htacess文件,我将不胜感激,如果有人会帮助我,请在此提前感谢您。

.htaccess文件的内容:

<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/ # RedirectTemp cannot be used instead 
    </IfModule> 
</IfModule>

1 个答案:

答案 0 :(得分:1)

您考虑过the "Configuring a web server" part of the symfony book吗?

摘录:

<VirtualHost *:80>
    ServerName domain.tld
    ServerAlias www.domain.tld

    DocumentRoot /var/www/project/web
    <Directory /var/www/project/web>
        # enable the .htaccess rewrites
        AllowOverride All
        Order allow,deny
        Allow from All
    </Directory>

    ErrorLog /var/log/apache2/project_error.log
    CustomLog /var/log/apache2/project_access.log combined
</VirtualHost>

AllowOverride All声明在这里很重要。如果缺少这个,则不允许在.htaccess文件中定义规则。