404 ResponseRedirect

SOS Childrensvillages asked on April 19, 2018 16:46

Hi,

I want my 404's to redirect to /pagenotfound and for the url to also change to /pagenotfound. What I have tried is:

<customErrors mode="RemoteOnly" redirectMode="ResponseRedirect" defaultRedirect="~/CMSMessages/CustomError.aspx">
      <error statusCode="404" redirect="~/PageNotFound" responseMode="redirect"/>
    </customErrors>

But when I try mysite.com/fjdkjfkdsajfdklajf it still seems to rewrite the error page into mysite.com/fjdkjfkdsajfdklajf (ie, the url doesn't change.).

Is there something I am missing?

Thanks in advance

Correct Answer

SOS Childrensvillages answered on April 30, 2018 09:53

In case anybody is reading I got an answer from kentico themselves:

This behavior is correct from SEO point of view. Previously we had the behavior you wanted but it was really bad for SEO to do a redirection so it was changed and just the 404 status code is returned and the URL is the same. If you want to change this behavior, you can create custom event handler and in the request end event check the status code and if it is 404, do a redirection - but this can harm your SEO rankings. https://docs.kentico.com/k11/custom-development/handling-global-events/reference-global-system-events#Reference-Globalsystemevents-RequestEvents

0 votesVote for this answer Unmark Correct answer

Recent Answers


Dragoljub Ilic answered on April 19, 2018 17:01 (last edited on April 19, 2018 17:02)

Hi,

There is several more steps that needs to be done. Please check more on this link https://docs.kentico.com/k11/securing-websites/developing-secure-websites/handling-error-messages-securely/creating-custom-error-handling-pages

Best regards, Dragoljub

0 votesVote for this answer Mark as a Correct answer

SOS Childrensvillages answered on April 20, 2018 09:04

Hi Dragoljub,

forgot to say I was on Kentico 10. But I followed the steps as outlined here.

I only highlighted the above setting as it seemed the most relevant (ie, redirect instead of rewrite).

0 votesVote for this answer Mark as a Correct answer

Amit Srivastava answered on April 20, 2018 11:51 (last edited on April 20, 2018 19:27)

Hi,

change mode from RemoteOnly to On.

<customErrors mode="On" redirectMode="ResponseRedirect" defaultRedirect="~/CMSMessages/CustomError.aspx">
      <error statusCode="404" redirect="~/PageNotFound" responseMode="redirect"/>
    </customErrors>

Hope will work.

1 votesVote for this answer Mark as a Correct answer

SOS Childrensvillages answered on April 20, 2018 14:37

Hi Amit, valid values are "On|Off|RemoteOnly" and I've tried them all.

0 votesVote for this answer Mark as a Correct answer

SOS Childrensvillages answered on April 26, 2018 11:33

Should I create a bug then?

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.