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


Symfony2 cant access app_dev.php unless removing .htacess file in web folder

Symfony2无法访问app_dev.php,除非删除web文件夹中的.htaccess文件,如果有人能帮我,我将不胜感激,提前谢谢。

.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>

您是否考虑过symfony书中的"配置web服务器"部分?

摘录:

<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文件中定义规则。