【问题标题】:Change Default Error Catch in htaccess?更改 htaccess 中的默认错误捕获?
【发布时间】:2016-03-08 13:26:02
【问题描述】:

所以我的问题与本页提出的问题类似

Single ErrorDocument directive to catch all errors (.htaccess)

上面的人试图获取动态错误页面。

但是我的问题略有不同(尽管它可能仍然有相同的答案)。

我与一个共享的网络主机合作,该主机默认显示自定义错误页面,上面有广告。我希望错误能够在没有广告的情况下产生真正的错误响应。我需要单独做一个:

 ErrorDocument 404     /404.html

对于每个错误?或者有没有办法告诉它显示所有错误的正常错误消息?

是否有某种类型:

ErrorDirective JustOutputErrorInsteadOfRedirecting

提前谢谢你。

【问题讨论】:

    标签: apache .htaccess mod-rewrite errordocument


    【解决方案1】:

    使用 ErrorDocument 指令,您还可以在同一页面上显示您的自定义错误消息。

    ErrorDocument 404 "Sorry, the page does not exist!"
    
    ErrorDocument 403 "Ohh, you don't have permission to access this page!"
    
    
    ErrorDocument 410 "Sorry, the page no longer exists"
    

    您还可以使用 html 标签格式化这些消息

    ErrorDocument 404 "<h2>Sorry, the page does not exist!</h2>"
    
    ErrorDocument 403 "<h2 style='color:blue'>Ohh, you don't have permission to access this page!</h2>"
    
    
    ErrorDocument 410 "<p>Sorry, the page no longer exists</p>"
    

    消息将显示在同一页面上。

    【讨论】:

      猜你喜欢
      • 2016-09-25
      • 1970-01-01
      • 2017-04-24
      • 2018-06-04
      • 1970-01-01
      • 2013-09-19
      • 1970-01-01
      • 1970-01-01
      • 2013-05-08
      相关资源
      最近更新 更多