Improve SEO for custom error pages
Hey guys,
I don't know if this is the right section but I would like to ask if anybody knows the answer to this little issue i am experiencing.
so basically when page is not found the sitefinity redirects to a custom Error page (404); by
using Fiddler, I noticed before landing on the Custom Error Page, the page I requested gets a 302 status.
Having 302 followed by a 404 kind of sucks from an SEO perspective.
I guess my question is, It is possible to make the 302 into 301 instead?
Hello Max,
I could suggest to insert some code in your global.asax file. Something similar to this could do the trick:
protected
void
Application_Error(
object
sender, EventArgs e)
Exception ex = Server.GetLastError();
if
(ex
is
HttpException)
var context = HttpContext.Current;
context.Response.Clear();
context.Response.Status =
"301 Moved Permanently"
;
context.Response.AddHeader(
"Location"
,
"customErrorPage"
);
context.Response.StatusCode = 301;
context.Response.End();
Thank you for the reply,
I used the code you provided but I still receiving 302 error then 404
FYI: I have Sitefinity 5.1 i don't know if it helps or not.
Hello Max,
Actually this should not be related with the Sitefinity version you are using. Here is a video of my test, which works as expected.
Regards,
Vassil Vassilev
Telerik