Re: If isset query_string return 404



"Justin Koivisto" <justin@xxxxxxxxx> wrote in message
news:3-OdnWt1V_fJm1DeRVn-ow@xxxxxxxxxxxx
>d wrote:
>> "Justin Koivisto" <justin@xxxxxxxxx> wrote in message
>> news:8fGdnfvFR67enVDeRVn-ow@xxxxxxxxxxxx
>>> d wrote:
>>>> "wd" <n23@xxxxxxxxxxxxxx> wrote in message
>>>> news:pan.2006.01.17.11.23.23.321125@xxxxxxxxxxxxxxxxx
>>>>> 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");
>>> [snip]
>>>
>>>> That's because $_SERVER["QUERY_STRING"] is *always* set, regardless of
>>>> whether there's a query string or not.
>>> Not true. With apache, QUERY_STRING will always be set; however, with
>>> other web server software (ie. MS IIS) it will never be set unless you
>>> have done so yourself.
>>
>> Incorrect. I tested it with Apache and IIS. BOTH have
>> $_SERVER["QUERY_STRING"] set regardless of whether a query string is
>> present
>> or not.
>
> Just because your IIS server has it does not mean that is the default.
> My install (and every other install that I have used) does not *ever*
> have it set. My version is (as reported by $_SERVER['SERVER_SOFTWARE'])
> "Microsoft-IIS/5.1"

See my other posts.

>>> Therefore, to be more portable, you may want to do something more like
>>> this:
>>>
>>> if(isset($_GET) && is_array($_GET) && count($_GET)){
>>> header("HTTP/1.0 404 Not Found");
>>> echo <<< HTML
>>> <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;
>>> exit;
>>> }
>>
>> I don't want to sound rude, but that's ridiculous.
>
> ...but you just did.
>
>> Just check to see if
>> $_SERVER["QUERY_STRING"] is a non-empty string. If it is, then
>> hey-presto,
>> you're set. You don't need to call isset, is_array and count all in one
>> go.
>
> And then when you install to another server like Netscape? Zues? AOL?
> Roxen? thttpd? The list goes on. You cannot *expect* a server to have
> $_SERVER['QUERY_STRING'] set in all cases.
>
> --
> Justin Koivisto, ZCE - justin@xxxxxxxxx
> http://koivi.com


.



Relevant Pages

  • Re: I hate IIS - "Server Application Unavailable" error message
    ... I would but there is not "Application Pools" underneath the local ... Did you install, at least, the Web or Standard versions of Windows Server 2003? ... except when you choose to install IIS on a domain controller. ...
    (microsoft.public.dotnet.framework.aspnet)
  • RE: Internet printing
    ... Configuring the IPP Print Server: ... (IIS is synonymous with PWS, Peer Web Services, which is what ... -This will install and configure basic IIS on the current machine. ...
    (microsoft.public.windows.server.sbs)
  • Re: No DHCP in administrative tools
    ... OK, we need to install the DHCP service, but we're gonna hold of a mo' on ... In computer management, expand IIS, expand websites, which sites do you ... SQL Server Config ...
    (microsoft.public.windows.server.sbs)
  • Re: OWA 403 Forbidden, POP3,
    ... Is there a way to just re-install the IIS components to a set of Default ... incorrect type of install of Trend not in a virtual directory was probably ... From your post, I understand you after you rebuild SBS Server, you ... Go to your "%SystemRoot%\IIS Temporary Compressed Files" ...
    (microsoft.public.windows.server.sbs)
  • [NT] Heap Overrun in HTR Chunked Encoding Could Enable Web Server Compromise
    ... This patch eliminates a newly discovered vulnerability affecting Internet ... in IIS 4.0 and 5.0, and could likewise be used to overrun heap memory on ... allowing code to be run on the server. ... * Microsoft has long recommended disabling HTR functionality unless there ...
    (Securiteam)