Thursday, 15 November 2012

SEO Friendly Custom Error Pages

SEO Friendly Custom Error Pages

The issue is that the most common
approach to serving up custom error pages is to use customErrors in
web.config which works by issuing a 302 to redirect
the client to the specified error page. The problem is that this
changes the status code from 404 or 500 to 302 instead, meaning that
missing pages are not removed from the search engine and that missing or
pages encountering an error will have the contents
of the error page cached for the requested url:

404 - missing page - search engine will remove page from cache
500 - error in code - search engine will ignore page not updating it's cache for that url
302 - temporary new location (redirect) - search engine will update the
cache of the original url with the contents of the new location
200 - page loaded ok - search engine will update it's cache for that url

Now ASP.NET 3.5 did introduce the ability to not perform a redirect
and instead simply serve up of the contents of the error page for the
requested url if you specify the attribute
redirectMode="ResponseRewrite". The problem is that this causes the
status
code to be changed back to 200, which is not we want. The solution
which only works on IIS7 is putting this in your web.config:

One of the configurations to be aware of is
existingResponse="Replace" because without this set the default error
page asp.net generates will be served up instead. This only works for
static html files so if you want your error pages to be dynamic aspx
files
instead you can choose to execute a url instead by specifying
responseMode="ExecuteURL" (htm files are better since they will still
work if you are uploading the site or when there's an error in the
Master page your error page inherits from). Unfortunately
this sets the status code back to 200, so in the code behind for your
error page you can call:

This could also be used with customErrors set to ResponseRewrite with
Response.TrySkipIisCustomErrors = true; in the code behind, but for
404's that don't end in an asp.net extension like .aspx say a typo like
.asxp it won't serve up your friendly 404 error
page, but if you use httpErrors it will.

To observe what status code is being served up I'm using Firebug on Firefox and looking under the net tab.

No comments:

Post a Comment

About Me

Hello Guys,My Name is Vishal Ranjan.. I am from India. My hometown is a small town named Katihar in North-East Bihar.I am an engineering graduate in the field of Information Technology. I am a Hard-Core C#.Net Programmer and a great fan of Microsoft Technologies. I am also the founder and Editor-In-Chief of www.dotnetvishal.com.. Currently Working for Bosch,Bangalore.

Flag Counter

Online User

World Map

Online Visitor Count

Google Page Rank

Daniweb

Total Pageviews

Disclaimer

The owner of this blog does not share personal information with third-parties nor does the owner store information is collected about your visit for use other than to analyze content performance through the use of cookies, which you can turn off at anytime by modifying your Internet browser’s settings. The owner is not responsible for the republishing of the content found on this blog on other Web sites or media without permission.

Blog Comments

The owner of this blog reserves the right to edit or delete any comments submitted to this blog without notice due to;

1. Comments deemed to be spam or questionable spam2. Comments including profanity3. Comments containing language or concepts that could be deemed offensive4. Comments that attack a person individually

Terms and Conditions

All content provided on this blog is for informational purposes only. The owner of this blog makes no representations as to the accuracy or completeness of any information on this site or found by following any link on this site. The owner will not be liable for any errors or omissions in this information nor for the availability of this information. The owner will not be liable for any losses, injuries, or damages from the display or use of this information.

This is a personal weblog. The opinions expressed here represent my own and not those of my employer My employer do not endorse any tools, applications, books, or concepts mentioned on the blog. I have documented my personal experience on this blog.

Please Do Not Copy The Content of this Website without the Proper Consent and Approval of the Owner of this Website. Any One Found Guilty of Copying the Content of this Website without the Consent of the Owner would be liable for Legal Proceedings against him or her and would even lead to DMCA Take-down of his or her Website/Blog without Prior Notice.

Note: If anyone find any material which is under any copyright license or anything objectionable. Please notify me @ my email Id: vishalranjan2k11@gmail.com. I assure you that appropriate action will be taken against the concerned material .