- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我知道这可能是重复的,但我有更好的细节。我将 .htaccess
文件设置为显示最常见错误的自定义错误页面:
# remove .php
RewriteEngine On
RewriteCond %{THE_REQUEST} /([^.]+)\.php [NC]
RewriteRule ^ /%1 [NC,L,R]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [NC,L]
#Add custom error pages
ErrorDocument 404 /errors/404
ErrorDocument 403 /errors/403
ErrorDocument 500 /errors/500
当我故意触发错误 500 时,它只是为我提供了默认的 Apache 页面,并且还说:此外,在尝试使用 ErrorDocument 处理请求时遇到了 500 Internal Server Error 错误。
我可以通过键入 localhost/errors/500
访问错误页面,所以这不是权限问题。我搜索了很多论坛,但没有找到解决方案。
编辑:错误 500 是由重写引擎的格式错误的请求触发的。如果您键入 example.com/index/
,它会尝试转到 /index/.php
,这会导致错误 500。
最佳答案
500 Internal Server Error 是一个非常普遍的错误。它表明服务器遇到了严重错误,无法正常处理请求。
这 500 个错误中的许多根本无法用 .htaccess
中定义为“后期”的自定义错误文档捕获。
如果在服务器配置中定义了 ErrorDocument
,您就有更好的机会。但即便如此,对于某些错误来说也还不够快。
不过,话虽如此......
...and also says:
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
I can access the error page by typing localhost/errors/500 so its not with the permissions.Edit: The error 500 was triggered from a malformed request by the rewrite engine. If you type
example.com/index/
it tried to go to/index/.php
and that caused error 500
看起来确实尝试提供自定义 (500) 错误文档,但这也遇到了 500 错误。
具体来说,请求 /index/
会导致重写循环,即。 /index/.php
到 /index/.php.php
到 /index/.php.php.php
等。当服务器达到内部重定向的限制(默认 10)是否会触发 500 错误。
是的,对于重写循环,我也看到了这一点。即使该错误似乎并未干扰 ErrorDocument 的服务;该消息似乎表明确实如此。直接请求错误文档即可。
我想知道(纯属假设)...由于此请求中已达到“内部重定向”限制(由于重写循环),无法提供 ErrorDocument(也由内部重定向提供服务)因为已经达到这个限制了!?因此,出于同样的原因,这会触发 500 错误!严格来说,ErrorDocument 是通过内部子请求(不是内部重定向)提供的,尽管 Apache documentation for the LimitInternalRecursion
directive似乎将“内部重定向”和“子请求”组合在一起。
我想不出另一种触发 500 错误的方法,除了在代码中触发它(如下 - 可以正常工作)。代码中的任何(致命)解析错误都会在每个请求上触发 500 错误。
RewriteRule ^foo$ - [R=500]
上面应该像往常一样为您的自定义 500 ErrorDocument 提供服务,ErrorDocument 本身是可以的。
关于错误 500 的 Apache ErrorDocument 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54353420/
我有一个带有多个虚拟主机的服务器。现在我想为整个服务器设置错误文档。我在 /var/www/error/* 中找到了我的错误站点,但使用 ErrorDocument指令我只能设置相对于文档根目录的错误
所以我有一个带有子目录的子域的apache服务器。我把我的目录变成子域。所以,而不是 example.site.com/mycoolsite它是 mycoolsite.example.com .或者换
有没有办法让您的PerlAuthenHandler,PerlAuthzHandler甚至您的PerlHandler更改请求的错误文档? 示例:当用户转到特定页面并收到错误消息时,我想让一个子例程选择将
我正在尝试对域及其所有子域使用相同的 404 ErrorDocument,子域在/var/www/路径中都有自己的目录 Apache ErrorDocument 指令需要一个相对路径(相对于当前目录)
在 Apache 中是否有这样的可能......(即重定向到一个外部 url,其路径导致 403 错误传递) ErrorDocument 403 http://www.sample.com/{{RED
我在子文件夹中有一个 htaccess 文件,如下所示: /subfolder/.htaccess 在 htaccess 文件中的以下代码设置一个 404 ErrorDocument ErrorDoc
请告诉我为什么这不起作用。它正在工作,但莫名其妙地决定停止工作。 在 php 中,如果找不到这样的页面,我会发出 404。 if(checkPageExists($escaped_url_page_n
我的 .htaccess 文件中有一堆 ErrorDocument 指令,以便捕获 Apache 可能向用户抛出的几乎所有可能的错误,并将所述用户重定向到我的错误 Controller ,然后将错误呈
我有一个 .htaccess 文件,如下所示: AddDefaultCharset utf-8 AddCharset utf-8 .html Order Allow,Deny ErrorDocumen
我有一个文件 index.php ,并在同一级别 .htaccess使用此代码: ErrorDocument 404 index.php 当我生成未找到错误时,会打印一个带有文件名的页面,因此,在这种
我希望将丢失文件和无效目录的请求重定向到自定义 404 错误页面。我相信这可以使用 2 种方法来完成。 # redirect invalid requests and missing files to
任何人都可以请指教吗?我希望我的网站访问者的默认页面是 index.php,对于所有不存在的页面,访问者应该看到 errordoc.php 所以我把它放在 .htaccess 中: ErrorDocu
我有一个来自 AWS EC2 服务的服务器,在 Linux ubuntu 上运行,并且我已经安装了 apache、php 和 mysql。 我已在文档根 /var/www/html 中添加了一个 .h
是否有类似通配符指令的东西可以捕获所有可能的错误并在单个自定义错误页面中处理它们? ErrorDocument 404 /error.php?code=404 ErrorDocument 403 /e
发生错误时,我正在尝试转移到另一台主机。我有这个,并且有效: ServerName test.com. ServerAlias test.com ProxyPreserveH
我想在我的项目中有一个自定义的 403 页面。所以我在 .htaccess 文件中添加了这些代码: Order deny,allow Deny from all Allow from 192.168.
我有多个ErrorDocuments在我的 .htaccess 文件中设置错误,例如 404、401、403 等,这些错误都重定向到我的错误页面,但 ErrorDocument当 PHP 报告 500
我基本上想要做的是将任何 404 请求重定向到 /404/但后来我想让它“拉”页面到 index.php?error=404 ,同时将 URL 保留为 /404/ - 然后我可以使用 PHP (使用
我的网站结构如下: - pages 404.php 403.php - app /css /-script index.php .htaccess 在我
我知道这可能是重复的,但我有更好的细节。我将 .htaccess 文件设置为显示最常见错误的自定义错误页面: # remove .php RewriteEngine On Rewr
我是一名优秀的程序员,十分优秀!