简体   繁体   English

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

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

I am installing Apache in CentOS 7 and this is my httpd.conf - http://pastebin.com/raw/YeiLn7GN 我在CentOS 7中安装Apache,这是我的httpd.conf - http://pastebin.com/raw/YeiLn7GN

This is my document root: /home/host/public_html 这是我的文档根目录: / home / host / public_html

To test if .htaccess file works & if mod_rewrite is enabled, I've uploaded the sample .htaccess from a laravel project into /home/host/public_html/.htaccess , which has the following contents: 要测试.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>

I then uploaded the following php script: /home/host/public_html/index.php 然后我上传了以下php脚本: /home/host/public_html/index.php

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

When I visit http://<my-server-ip>/index.php , I get the following error: 当我访问http://<my-server-ip>/index.php ,我收到以下错误:

500 Internal Server Error 500内部服务器错误

I got found the following in /var/log/httpd/apache_error_log file: 我在/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: Options not allowed here [Thu Dec 31 15:50:43.696465 2015] [core:alert] [pid 23807] [client xxx.xxx.xxx.xxx:56536] /home/host/public_html/.htaccess:此处不允许选项

If I remove the following lines from the .htaccess file: 如果我从.htaccess文件中删除以下行:

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

The script appears to load and no 500 error. 脚本似乎加载,没有500错误。

Any ideas what might be wrong? 什么想法可能是错的?

.htaccess: Options not allowed here error indicates that the htaccess file is not allowed to use the Options directive to change the settings. .htaccess:此处不允许的选项错误表示不允许 htaccess文件使用Options指令更改设置。

To fix this error edit your apache config file /etc/httpd/conf/httpd.conf :- 要修复此错误,请编辑您的apache配置文件/etc/httpd/conf/httpd.conf : -

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

Adding "Options" to the AllowOverride list, will permit the use of Options directive in htaccess file 将“选项”添加到AllowOverride列表中,将允许在htaccess文件中使用Options指令

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM