Forum Moderators: phranque
Currently we are a MS shop running our web server farm on IIS. Our web servers have a custom 404 page defined via IIS. The custom 404 page puts up messaging to let the user know they have requested a page that does not exist with links back to our site (basically the standard global nav and footers) and returns a 404 status. Below is how the interaction between the browser and web server currently works:
1) Browser requests a page that does not exist (http://www.example.com/badpagename.asp).
2) IIS determins the page does not exist and returns a 302 status to the browser indicating that the page was temporarily moved to http://www.example.com/unknown/404.asp?404;http://www.example.com/badpagename.asp which is our custom 404 page. This is handled totally by IIS . IIS automatically adds the '?404;http://www.example.com/badpagename.asp' to the URL of a custom 404 by default.
3) Browser follows the temporary redirect and requests the custom 404 page at http://www.example.com/unknown/404.asp?404;http://www.example.com/badpagename.asp
4) Web server displays the custom 404 page and returns a 404 status to the browser.
Is this the proper interaction between browser and server for a custom 404 page? It just doesn't seen correct to me that the browser address bar (because it was a 302 redirect) has the URL of the custom 404 page in it when it gets the status 404. Maybe I'm wrong but if I were a browser I would interpret that as meaning the custom 404 page does not exist.
The following seems like a more 'proper' implementation of a custom 404 page:
1) Browser requests a page that does not exist (http://www.example.com/badpagename.asp).
2) IIS determines the page does not exist, perform a URL rewrite so that the HTML returned is from the custom 404 page (without redirecting), and returns a 404 status to the browser instructing it that the original page that was requested does not exist.
This way the browser address bar has in it the original bad URL when the 404 status is returned.
Or is the first method correct because the browsers and search engines see the target of the 302 as if it were the original page that was requested even since it has been 'temporarily' moved?
Just curious how others handle their 404s.
Serving a 302 redirect is incorrect.
I'm not sure about IIS, but a common error on Apache servers is to specify a full URL for the error page, i.e. http://www.example.com/404error.php or similar. If a full URL is specified, Apache does not check to see if that URL is actually located on the same site, it simply issues a 302 redirect to that URL.
So, on Apache, the path to the custom error page should be specified only as a local path, relative to server root, i.e. /404error.php
I suspect a similar problem on your site, as I can't believe that IIS would 'get it wrong' under all circumstances -- The hue and cry would be deafening (and would have happened long ago, and would have resulted in a quick fix). So there is likely to be a configuration error or some little 'trick problem' like this one that happens with Apache when a full erro page URL is specified.
Jim
I had to make the custom 404 page an asp page then point the custom 404 page set up in IIS to the 404.asp page.
Works fine.
<%
Response.Status = "404 Not Found"
%>
Whey this isnt told in the IIS help is not know but this was a sure fix for me.
<%
Response.Status = "404 Not Found"
%>
So my error page is returning a 404 status which is correct (if the original URL were still in the browser address bar). Prior to adding the above line it was returning a 200. If I could just make IIS do a URL rewrite of the requested URL to my custom 404 page rather than 302 redirecting the user to my 404.asp... then life would be good.
I thought Jim Morgan might be on to something, so I checked one of our web servers. IIS is already configured with a root relative custom 404 URL, not a fully qualified URL. So it doesn't appear to be a problem similar to the Apache configuration error he mentioned.
[edited by: ZydoSEO at 8:56 pm (utc) on Sep. 24, 2008]
So my error page is returning a 404 status which is correct (if the original URL were still in the browser address bar
The original URL does stay in the browser bar on my setup.
Let me remote in and see what url path I have been sometime since I set it up.
so in the IIS HTTP header tag 404 is show the url /404.asp
You said file but you mean page right.