Forum Moderators: coopster & phranque

Message Too Old, No Replies

Help with 404 Custom error handling

getting 302 instead if 200

         

Night_Hawk

12:35 am on Jan 21, 2003 (gmt 0)

10+ Year Member



Hi Everyone,

I have a custom error that is half way working, the part that i need help with is the following:

I have some page indexed by inktomi but the pages are no longer exist,
the format of the url for these pages like this
[mydomain.com...]

I have the following vbscript code to get the 999 from the url and do server.transfer(/Allcars.asp) passing the 999 through a session variable. here is the code

Response.Status = "200 OK"
strURL = Request.ServerVariables("HTTP_HOST") &
Request.ServerVariables("URL") &
Request.ServerVariables("QUERY_STRING")

If Len strURL > 15 and Right strURL, 9 = "index.asp" Then
strURL = Left(strURL, Len(strURL) - 10)
PidPosition = InStrRev(strURL, "-")
Pid = Right(strURL, Len(strURL) - PidPosition)
Session("404productId") = clng(Pid)
Server.Transfer("/Allcars.asp")
end if

This is the part i am having proplems with, it suppose to return the a 200 but according to the logs it is returning a 302.

and the url in the browser is changing from the
[mydomain.com...] to

[mydomain.com...]

is this the correct way of doing it or should i do it some other way?.
Please help.
AJ

Dreamquick

9:36 am on Jan 21, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



As far as I am aware that's an IIS issue which I think they finally fixed with v5.1 (XP), but don't quote me on that.

Basically the way it seems to work is that if you only use stuff within your custom script and don't try to send the user elsewhere (redirection) then IIS happily gives them the script on the first request - ie if its a genuine 404 then the first page they see is a 404.

However if you try to redirect or server.execute etc. then IIS issues a 302 to your custom script which then executes once the user requests it.

Admittedly it is a pain but as someone who's using a similar setup it doesn't seem to scare SE spiders - most happily follow my 301 & 302 and update their databases accordingly (I imagine most people using IIS have the same problem so it's *not* just you).

- Tony