【发布时间】:2016-04-05 17:27:21
【问题描述】:
我在 CentOS 7 中安装 Apache,这是我的 httpd.conf - http://pastebin.com/raw/YeiLn7GN
这是我的文档根目录:/home/host/public_html
为了测试.htaccess 文件是否有效以及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 文件中找到了以下内容:
[Thu Dec 31 15:50:43.696465 2015] [core:alert] [pid 23807] [client xxx.xxx.xxx.xxx:56536] /home/host/public_html/.htaccess: 此处不允许选项
如果我从 .htaccess 文件中删除以下行:
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
脚本似乎正在加载并且没有 500 错误。
有什么想法可能是错的吗?
【问题讨论】:
标签: php apache .htaccess mod-rewrite centos7