CentOS Apache.htaccess:此处不允许选项(500-内部服务器错误)


CentOS Apache .htaccess: Options not allowed here (500 - Internal Server Error)

我正在CentOS 7中安装Apache,这是我的httpd.conf-http://pastebin.com/raw/YeiLn7GN

这是我的文档根目录:/home/host/public_html

为了测试CCD_ 1文件是否工作&如果启用了mod_rewrite,我已经将示例.htaccess从laravel项目上传到了/home/host/public_html/.htaccess中,其中包含以下内容:

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>
    RewriteEngine On
    # Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ /$1 [L,R=301]
    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

然后我上传了以下php脚本:/home/host/public_html/index.php

<?php echo '<pre>'; print_r($_SERVER); ?>

当我访问http://<my-server-ip>/index.php时,我得到以下错误:

500内部服务器错误

我在/var/log/httpd/apache_error_log文件中发现了以下内容:

【2015年12月31日星期四15:50:43.696465】【核心:警报】【pid 23807】【客户端xxx.xxx.xxx:56536】/home/host/public_html/.htaccess:此处不允许选项

如果我从.htaccess文件中删除以下行:

<IfModule mod_negotiation.c>
    Options -MultiViews
</IfModule>

脚本似乎已加载,没有500错误。

有什么想法吗?

.htaccess:此处不允许选项错误表示不允许htaccess文件使用Options指令更改设置。

要修复此错误,请编辑apache配置文件/etc/httpd/conf/httpd.conf:-

<Directory /var/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride Options
    Order allow,deny
    allow from all
</Directory>

将"Options"添加到AllowOverride列表中,将允许在htaccess文件

中使用Options指令