【问题标题】:500 Internal Server Error on PHP Site on Page that DOESN'T exists500 页面上的 PHP 站点上的内部服务器错误不存在
【发布时间】:2018-02-23 13:58:21
【问题描述】:

查看我的搜索控制台,我发现了一些服务器错误。令我惊讶的是,我在一个不存在的子目录中收到 500 内部服务器错误。但是我有一个 404 重定向,您可以在任何其他不存在的子目录或页面上获得它。也许几个月前该站点的子目录曾经存在,但我不再在我的服务器中看到它。我检查了 .htaccess,一切都很简单:

RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://fryla.com.ar/$1 [R,L]

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

ErrorDocument 404 https://www.fryla.com.ar/404

例如,我收到以下错误: https://www.fryla.com.ar/portfolio/anything 但不在: https://www.fryla.com.ar/anyotherdir/something https://www.fryla.com.ar/anyotherdir/

编辑: 我按照建议查看日志(我无权购买我的主机为我提供日志)。错误是:

Request exceeded the limit of 10 internal redirects due to probable 
configuration error. Use \'LimitInternalRecursion\' to increase the limit if 
necessary. Use \'LogLevel debug\' to get a backtrace.

但就像我说的,我的 htaccess 中没有任何重定向。有什么想法吗?

提前谢谢!!!

【问题讨论】:

  • A 500 错误是一种通用错误消息,几乎涵盖了脚本可能出错的每一件事。检查您的服务器错误日志以找出确切的错误消息。
  • 检查您的服务器日志,因为您可能设置了错误的 .htaccess 重写
  • 在哪里可以找到服务器日志?抱歉,它不在我的 public_html 目录中。也许我必须以某种方式启用它? Tks
  • 如果您将规则从 RewriteRule ^(.*)$ $1.php 更改为 RewriteRule ^(.*)/?$ $1.php 是否有效?我在您的模式中添加了一个可选的斜杠。
  • 它可以工作,但它根本不能解决我的问题。我仍然在同一页面中收到 500 错误页面。

标签: php html .htaccess


【解决方案1】:

尝试将ErrorDocument 404 https://www.fryla.com.ar/404 更改为位置ErrorDocument 404 /404。删除了一个额外的RewriteEngine On,因为只需要 1 个

复制以下内容:

RewriteEngine On 

RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://fryla.com.ar/$1 [R,L]
RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
ErrorDocument 404 /404.html

编辑:更新到错误文档位置

【讨论】:

  • 该代码刚刚破坏了整个站点,“ErrorDocument 404/404”行是问题...
  • @Fryla-CristianMarucci 404.html 页面的位置在哪里?编辑:更新位置以包含 .html
  • 我试过了,但我不认为这是这里的问题。我现在只使用了一个 RewriteEngine 但问题的问题仍在发生。无论如何,谢谢。
  • 这是您的 404 重定向吗? RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://fryla.com.ar/$1 [R,L] RewriteCond %{REQUEST_FILENAME} !-d
【解决方案2】:

我找到了解决方案...这曾经是我的 .htaccess,用于删除每个页面的 php 扩展名:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

现在,我找到了另一个代码,并且错误消失了。新代码是:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

感谢大家的帮助!

【讨论】:

    猜你喜欢
    • 2016-04-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-12
    • 2012-10-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多