【问题标题】:Error if RewriteEngine On - says FollowSymLinks is off如果 RewriteEngine On 出现错误 - 表示 FollowSymLinks 已关闭
【发布时间】:2014-07-25 17:02:19
【问题描述】:

我到处搜索(包括这里),但找不到正确答案!

我已经接管了一个新设置的网络服务器的控制权,但所有的设置可能都不是理想的(还),但我无法在 .htaccess 文件中使用 RewriteEngine On。错误日志显示无法完成,因为 FollowSymLinks 已关闭。

除了我看不到它在哪里关闭!

这是带有 Apache 5.4.30 的 CentOS 版本 6.5(最终版)

网络文件存储在 /home/domain-name/public_html 和 httpd.conf 有(除其他外)

<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>

DocumentRoot "/var/www/html"

<Directory "/var/www/html">
    Options Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

<Directory /home/*/public_html>
    Options +ExecCGI +FollowSymLinks +Includes -Indexes +MultiViews
    XBitHack On
    AllowOverride All
    DirectoryIndex index.html index.html.var index.htm index.shtml index.php default.html default.htm default.shtml
</Directory>

<VirtualHost *:80>
        DocumentRoot /var/www/html
        ServerName server52218.uk2net.com
        <Directory /var/www/html>
            Options ExecCGI FollowSymLinks Includes IncludesNOEXEC Indexes MultiViews
            XBitHack On
            AllowOverride All
            DirectoryIndex index.html index.html.var index.htm index.shtml index.php default.html default.htm default.shtml
        </Directory>
</VirtualHost>

<Directory "/var/www/sites">
    Options ExecCGI FollowSymLinks Includes -Indexes MultiViews
    XBitHack On
    AllowOverride All
    DirectoryIndex index.html index.html.var index.htm index.shtml index.php default.html default.htm default.shtml
    Order allow,deny
    Allow from all
</Directory>

单个站点配置文件没有什么特别之处;指定 DocumentRoot、ScriptAlias、ServerName/Alias 和 Logs。

如果网站需要使用重写,.htaccess 文件会启用 RewriteEngine,这会导致错误发生并显示在错误日志中。删除该行,网站显示 OK(当然,重写现在不起作用!)

这与他们在旧服务器上的设置完全相同(据我所知),但运行的是 CentOS 5.10 和 Apache 2.2.3

我已经尝试在 htaccess 文件中指定 Options 指令,但仍然不满意。

我错过了什么?下一步我该往哪里看??

通常 /home/domain-name/public_html/.htaccess 包含

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

【问题讨论】:

  • 你的 htaccess 文件是什么样的?
  • .htaccess 文件的位置在哪里?
  • 我在上面的问题中添加了一个典型的 htaccess 文件(似乎无法在此评论中进行格式化)。

标签: apache .htaccess mod-rewrite


【解决方案1】:

看起来这一切都归结为 /etc/httpd/conf.d/welcome.conf 中的一条声明

<LocationMatch "^/+$">
    Options Indexes
    ErrorDocument 403 /error/noindex.html
</LocationMatch>

将选项语句更改为

Options -Indexes

似乎让事情再次发生了。不过,我不确定为什么。

【讨论】:

    猜你喜欢
    • 2011-12-01
    • 2014-05-02
    • 2020-12-07
    • 2012-08-07
    • 2015-07-01
    • 2015-11-25
    • 2013-03-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多