gpt4 book ai didi

php - 尝试使用 ErrorDocument 处理请求时出现 500 Internal Server Error

转载 作者:可可西里 更新时间:2023-10-31 22:14:27 24 4
gpt4 key购买 nike

我有这个 .htaccess 文件:

Options -Indexes
RewriteEngine on

ErrorDocument 404 /404.php

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([^/]*)/?(.*)$ ./$1.php

RewriteCond %{THE_REQUEST} \.php
RewriteRule ^(.*)$ - [L,R=404]

但是,当我转到 localhost/example.php 时,它返回 500 Internal Server Error。

有什么帮助吗?谢谢。

编辑:

出现的完整错误信息是:

Not Found

The requested URL /example.php was not found on this server.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

最佳答案

由于循环错误,您很可能得到 500。

从最后一条规则中排除 404.php 为:

ErrorDocument 404 /404.php

Options -Indexes -MultiViews
RewriteEngine on

RewriteCond %{THE_REQUEST} \.php [NC]
RewriteRule ^(?!404\.php)$ - [L,NC,R=404]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([^/]+)/?(.*)$ ./$1.php [L]

关于php - 尝试使用 ErrorDocument 处理请求时出现 500 Internal Server Error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20752140/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com