帮助:如果isset query_string返回404 [英] Help: If isset query_string return 404

查看:71
本文介绍了帮助:如果isset query_string返回404的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果带有查询字符串的网址是

,我希望我的服务器发送404标头。因此,如果浏览器或蜘蛛请求



www。 my_site .com?p =主席

他们会得到404 ...


但如果他们要求

www。 my_site .com / chair.htm

一切都会正常。


有了一些帮助,这是我到目前为止所做的,但是它没有工作

正确。它总是显示404,即使URL中没有问题

标记。此外,我希望该页面在HTML>>>之后停止显示任何内容

如果它发送404错误,但我不知道怎么做

it:

if(isset($ _ SERVER [" QUERY_STRING"])){

header(" HTTP / 1.0 404 Not Found");

echo<<< HTML


< ; head>

< title> 404 Not Found< / title>

< / head>

< body>

< h1>未找到< / h1>

在此服务器上找不到请求的网址。

< / body>

< / html>


HTML>>> ;;


}

解决方案

_SERVER [" QUERY_STRING"])){

header(" HTTP / 1.0 404 Not Found");

echo<<<< HTML


< head>

< title> 404 Not Found< / title>

< / head>

< body>

< h1>未找到< / h1>

在此服务器上找不到请求的URL。

< /正文>

< / html>


HTML>>> ;;


}


" wd" < n2*@nospam.invalid>在留言中写道

news:pa **************************** @ nospam.invalid ... < blockquote class =post_quotes>如果请求带有查询字符串的URL,我希望我的服务器发送404标头。因此,如果浏览器或蜘蛛请求像
www。 my_site .com?p =主席
他们会得到404 ......

但如果他们要求
www。 my_site .com / chair.htm
一切都很正常。

有了一些帮助,这是我到目前为止所做的,但是它没有正常工作。它总是显示404,即使URL中没有问题
标记。此外,我希望该页面在HTML>>>之后停止显示任何内容。如果它发送404错误,但我不知道怎么做
它:

if(isset(


_SERVER [" QUERY_STRING"])){
标题(" HTTP / 1.0 404 Not Found");
echo<<< HTML

< head>
< title> 404 Not Found< / title>
< / head>
< body>
< h1>未找到< / h1>
请求的网址在此服务器上找不到。
< / body>
< / html>

HTML>>> ;;

}




那是因为


I want my server to send a 404 header if a URL with a query string is
requested. So if a browser or spider requests something
like
www. my_site .com?p=chair
they would get a 404...

But if they request
www. my_site .com/chair.htm
everything would be normal.

With some assistance this is what I have so far, but it isn''t working
correctly. It always displays the 404, even when there is no question
mark in the URL. Also, I would like the page to stop displaying anything
after the "HTML>>>" if it sends the 404 error, but I''m not sure how to do
it:
if (isset($_SERVER["QUERY_STRING"])) {
header("HTTP/1.0 404 Not Found");
echo <<<HTML

<head>
<title>404 Not Found</title>
</head>
<body>
<h1>Not Found</h1>
The requested URL was not found on this server.
</body>
</html>

HTML>>>;

}

解决方案

_SERVER["QUERY_STRING"])) {
header("HTTP/1.0 404 Not Found");
echo <<<HTML

<head>
<title>404 Not Found</title>
</head>
<body>
<h1>Not Found</h1>
The requested URL was not found on this server.
</body>
</html>

HTML>>>;

}


"wd" <n2*@nospam.invalid> wrote in message
news:pa****************************@nospam.invalid ...

I want my server to send a 404 header if a URL with a query string is
requested. So if a browser or spider requests something
like
www. my_site .com?p=chair
they would get a 404...

But if they request
www. my_site .com/chair.htm
everything would be normal.

With some assistance this is what I have so far, but it isn''t working
correctly. It always displays the 404, even when there is no question
mark in the URL. Also, I would like the page to stop displaying anything
after the "HTML>>>" if it sends the 404 error, but I''m not sure how to do
it:
if (isset(


_SERVER["QUERY_STRING"])) {
header("HTTP/1.0 404 Not Found");
echo <<<HTML

<head>
<title>404 Not Found</title>
</head>
<body>
<h1>Not Found</h1>
The requested URL was not found on this server.
</body>
</html>

HTML>>>;

}



That''s because


这篇关于帮助:如果isset query_string返回404的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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