簡體   English   中英

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

要測試.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錯誤。

什么想法可能是錯的?

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

將“選項”添加到AllowOverride列表中,將允許在htaccess文件中使用Options指令

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM