包含在PHP 404标题返​​回后“哎呀!此链接似乎已被破坏。“ [英] include after PHP 404 header returning "Oops! This link appears to be broken."

查看:136
本文介绍了包含在PHP 404标题返​​回后“哎呀!此链接似乎已被破坏。“的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

总而言之,我在一个显示评论的网站上有动态页面。如果没有与特定城市/县/区域/等相关联的评论,则mysql查询返回0行,触发以下代码:

To make a long story short, I have dynamic pages on a website that display reviews. If there are no reviews associated with a particular city/county/area/etc the mysql query returns 0 rows which triggers the following code:

if (!$validRevQuery) {
    header("HTTP/1.0 404 Not Found");
    include("http://{$PDS['site']}/404.php?request=".urlencode($_SERVER['REQUEST_URI']));
    exit;
}

在某些webhost上,这会触发URL文件访问被禁用错误。哪个没问题,但在允许访问URL文件的文件中,包含并正确显示404文件。我稍微更改了代码以显示如下的绝对路径:

On some webhosts this triggers a "URL file-access is disabled" error. Which is fine, but on the ones that allow URL file-access, the 404 file is included and properly displayed. I changed the code slightly to display an absolute path like so:

if (!$validRevQuery) {
    header("HTTP/1.0 404 Not Found");
    $_GET['request'] = urlencode($_SERVER['REQUEST_URI']);
    include($_SERVER['DOCUMENT_ROOT']."/404.php");
    exit;
}

现在,它给了我通用的哎呀!这个链接似乎是破碎。错误页面。 (我有谷歌工具栏,所以这可能会有所不同,具体取决于浏览器和插件)。不知道为什么会这样,所以任何帮助都表示赞赏!

And now, it's giving me the generic "Oops! This link appears to be broken." error page. (I have google toolbar, so this may be different depending upon browser and plugins). No idea why this is happening, so any help is appreciated!

推荐答案

你的问题与你所包含的内容无关:它是您的网页太小了。

Your problem has nothing to do with what you include: It's that your page is too small.

根据我的经验,当网页仅发出时,会显示Chrome内置的糟糕页面,就像在Internet Explorer中一样404标题和少于定义的内容字节数(我认为它在IE中是512字节,不知道Chrome中的限制)。

In my experience, Chrome's built-in "Oops" page is displayed, like the one in Internet Explorer, when the page emits only the 404 header and less than a defined number of bytes of content (I think it's 512 bytes in IE, don't know the limit in Chrome).

我倾向于在我的404页面中填入HTML注释中包含的几百字节无意义内容,以确保显示自定义404页面。

I tend to pad my 404 pages with a few hundred bytes of meaningless content wrapped in HTML comments to make sure the custom 404 page is displayed.

或者当然,利用这个机会做一些很酷的事情 ASCII艺术

Or of course, use the opportunity for some cool ASCII Art!

   <!--                            oooo   ooo
                                   $   $  $   $
                                   "o  $ $  o""
                                     o  "   "ooooo
                                 oo ""           o$
                   o            o            oo  "
                  $$             $o$""$o  ooo$
                  $"$          o $    "$  $
        o$o       $ "$         $ $     $ $
         $$$o     $$ "$       o$ $     o $o
         "$ ""o   "$   "o     $$ "o     o"
     $o   $$   "o  $     "oo  $"  $   o$"
      "$   $o    "o$$       "o$    $o$" oo$
        "o "$o                     "$o $"$$
          "        oo$$$$$$$oo        $oo$$""      o" o
 """""""""      o$$$$$$$$$$$"$o             o"""$o$$  o$
       ooo$$$"o$$$$$$$$$$$$$$ "$o    o   o$$$o   $ $ o$
    o$$$$$$$$$$$$$$$$$$$$$$$$    "oo  o      ""o  "$ $
   $$$$$$$$$$$$$$$$$$$$$$$$$$      "$o   o$$"""$     " oo""o
o""""$$$$$$$$$$$$$$$$$$$$$$"         ""$o"$o          "   o$
     "$$$$$$$$""""$""$$$""              "$oo$""$o     o$"""
      $$$$$$$"                           $""""$"  o""""
       $"""""$ooooo        ooooo$$$$$$$     o$" o"
        $     """" oooo$$$$$$$$$$$$$$"     $"  o"
      oo$   oooo$$$$$$$$$$$"""""$$$$"    o$" o$"
    "$ $o$$$$$$$$$$$$$""$     o$$$"oooo$"  o"
      "o$ "$$$$$$$$$$$$         $$o$"$$$   $"
        "$  ""$$$$$$$$$        o$"$$$ "$$o$$
          "o   ""$$$$$$o     o$$$$ ""$o """$
            "$o    ""$$$$$$o"  o$$$$oo o$$$$
               ""$oo     $$" "$$$"" ooooooo$
                    """"$"  o$"   oo$$$$$""$$
                       $ oo$"  o$$$$$""  ooo$
                       $o$"  o$$$$"  oo$$$$$$$o
                        $$ o$$$"  o$$$$$$"""""$o
                         "o$$"  o$$$$""  o$$$$$$$o
                           "$oo$$$$"  o$$$$$""" o$o
                             "$$$" oo$$$"" oo$$$$$$$
                          ooooo$oo$$$"" oo$$$$"""$$""
                         $"oooo $$$" o$$$$""      $
                       o$"o$   $$"oo$$""       " o$
                       $ o$$o  $$o$$"          oo$$
                       $ $$$$  $$$$$$$$$$$$$$$$$$$$
                       $ $$$$  $$$$$$$$$$$$$$$$$$$$"
                       $ $$$$  $$$$$$$$$$$$$$$$$$$$
                       $ ""    ""$$$$$$$$$"""$""""
                       $o         $"$"    " $"
                        $o       $$  $o    o$
                         "$o   o$$    ""$$$"
                           """"""  -->

这篇关于包含在PHP 404标题返​​回后“哎呀!此链接似乎已被破坏。“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆