【问题标题】:Symfony2 cant access app_dev.php unless removing .htacess file in web folder除非删除 web 文件夹中的 .htaccess 文件,否则 Symfony2 无法访问 app_dev.php
【发布时间】:2014-07-04 06:39:38
【问题描述】:

除非删除 web 文件夹中的 .htacess 文件,否则 Symfony2 无法访问 app_dev.php,如果有人能在此帮助我,我将不胜感激,谢谢。

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

【问题讨论】:

  • 当您访问该站点时究竟发生了什么?您是否收到类似“您无权访问此文件。请检查...”之类的消息?
  • 不,它就像“内部服务器错误服务器遇到内部错误或配置错误,无法完成您的请求。请通过 webmaster@localhost 与服务器管理员联系,告知他们发生此错误的时间,以及您在此错误之前执行的操作。有关此错误的更多信息可能在服务器错误日志中可用。"而且我也无法在列表索引中看到网络目录。
  • 能否提供您的.htaccess 文件的内容。
  • 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 重写规则 .? - [L] 重写规则 .? %{ENV:BASE}/app.php [L] RedirectMatch 302 ^/$ /app.php/ # RedirectTemp 不能代替

标签: php .htaccess symfony


【解决方案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 文件中定义规则。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-09
    • 2012-01-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多