Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Markus Johansson 1902 posts 5706 karma points MVP c-trib
    Mar 02, 2016 @ 22:28
    Markus Johansson
    0

    Return a 404 from a custom page

    Hi!

    I'm running a site where I have dynamic pages. For simplcity lets say it looks like this

    page.aspx?id=1 page.aspx?id=2 page.aspx?id=3 page.aspx?id=4

    If page 3 is deleted I would like to return a 404 header and show a custom error page saying... "Page nr 3 is not active any more yada yada yada".

    When I try this I end up in a never ending loop of 301 redirects, everything works until I return the 404-headers

    Response.Status = "404 Not Found";
    Response.StatusCode = 404;
    

    I'm thinking that the 404 handler in SEO Checker might be the resone for the never ending loop? Is there any way to ignore all the 404s comming from this page.aspx-file?

    // m

  • Richard Soeteman 4035 posts 12842 karma points MVP
    Mar 03, 2016 @ 05:51
    Richard Soeteman
    0

    Hi Markus,

    The redirect module kicks in in that case and I think there is a redirect rule that only looks at the page.

    4 things to solve this

    • Set the querystring option in redirect configuration then it will look at querystrings also.
    • Add the default.aspx to the ignore list.
    • Return a 410 status (deleted) instead of 404.
    • Add the default.aspx page to the ignores url's option in web.config

    Hope this helps,

    Richard

  • Markus Johansson 1902 posts 5706 karma points MVP c-trib
    Mar 03, 2016 @ 06:56
    Markus Johansson
    0

    Hi!

    Thank you Richard!

    Thanks! You mean page.aspx and not default.aspx right?

    Which of these options would you recommend? How do I add it to the "ignore list"? Is that a SEO Checker-feature?

    // m

  • Richard Soeteman 4035 posts 12842 karma points MVP
    Mar 03, 2016 @ 07:01
    Richard Soeteman
    0

    ehh yes page.aspx and yes ignore list in redirect manager is a SEO checker option (documented in the user manual ;-) ) when you click on delete you see that option.

    Hope this helps!

  • Markus Johansson 1902 posts 5706 karma points MVP c-trib
    Mar 03, 2016 @ 07:21
    Markus Johansson
    0

    Hi! Great =D

    Looking at the ignore-documentation it says:

    7.5 Ignore list Use the following ignore lists to show the items that will be ignored during > validation: - Ignored validation issues - Ignored inbound link errors - Ignored configuration issues

    The issue is not about the validation of the page it's about the redirects that just end's up in a loop. Does this ignore-configuration disable your http-handler for these document types?

    About this:

    Add the default.aspx page to the ignores url's option in web.config

    How could that be done?

  • Markus Johansson 1902 posts 5706 karma points MVP c-trib
    Aug 18, 2016 @ 19:23
    Markus Johansson
    0

    Hi again Richard!

    I've tried a couple of thing without success, what I'm doing is to change the status code in the code behind of my page like so:

        HttpResponse response = HttpContext.Current.Response;
        response.Status = "410 Deleted";
        response.StatusCode = 410;
    

    Really simple and straightforward. But the only thing that happens is that SEO Checkers module creates a 301 back to the same page over and over again. Look here from my Fiddler:

    enter image description here

    I've tried with:

    • The 410-status (as you can see in the code snippet),
    • Checked "ignore" this page in the "Redirect manager" in the SEO Checker-section in the backoffice.

    It still just ends up in a 301 loop, if I comment out the SEO Checker module in the root web.config everything works just fine and as expected.

    I think I might have found something that effects this. I have the "force www" option selected when the 301-loop is created BUT if I choose "Ignore" it all works just fine and the page returns a 410.

    It's obviously a bug in the package here that needs to be investigated and fixed. During this is there any way to configure SEO Checkers module to NOT handle the page.aspx-file that I'm having these issues with?

    If yes, please explain how and where I will configure this.

    enter image description here

  • Richard Soeteman 4035 posts 12842 karma points MVP
    Aug 19, 2016 @ 06:19
    Richard Soeteman
    0

    Hi Marcus,

    Did you set the querystring option also? I was wrong about statuscode 410. That triggers the notfound module also. and will cause the redirect loop.

    That the loop occurs is because there is a redirect from www to non www first or vice versa and then the original request is not the same as the page where you redirect to and causing that loop.

    But Hope querystring option works.

    Best,

    Richard

  • Markus Johansson 1902 posts 5706 karma points MVP c-trib
    Aug 19, 2016 @ 07:50
    Markus Johansson
    0

    Hi!

    I tried that as well. The thing is that when I delete something in the "Redirect Manager" it just comes back again on the next incoming request and it creates a new redirect to the same page.

    I was wrong about the "Ignore"-thing it must have been when I had comment out the moduel in web.config.

    I'll drop you an email so that I can share more details.

    / m

  • Richard Soeteman 4035 posts 12842 karma points MVP
    Aug 22, 2016 @ 08:38
    Richard Soeteman
    0

    Hi Markus,

    I've added an option to disable Notfound functionality for a request by setting SEOCheckerIgnore404Request to "true".

    So if you install the version below and change your snipper to the following it will not try to find the page again and will not redirect.

    HttpResponse response = HttpContext.Current.Response;
    response.Status = "410 Deleted";
    response.StatusCode = 410;
    response.Headers["SEOCheckerIgnore404Request"] = "true";
    

    1.9.4.1 prerelease can be found at https://www.dropbox.com/s/b3hetzibqc698s9/seo-checker1941.zip?dl=0

    Hope this helps,

    Richard

  • Markus Johansson 1902 posts 5706 karma points MVP c-trib
    Aug 23, 2016 @ 11:19
    Markus Johansson
    0

    Thanks! I'll give this a try and let you know!

    / m

  • Markus Johansson 1902 posts 5706 karma points MVP c-trib
    Sep 02, 2016 @ 07:29
    Markus Johansson
    0

    Hi Richard!

    Before I start to work on this.

    My client is on Umbraco 4.11.10, did you drop the V4-support in version 1.9.4?

    Is there any thing that would not work or have you just stopped to test against V4?

    // m

  • Richard Soeteman 4035 posts 12842 karma points MVP
    Sep 02, 2016 @ 08:06
    Richard Soeteman
    0

    Yup 4.11 should work, please test on staging first :)

  • Markus Johansson 1902 posts 5706 karma points MVP c-trib
    Sep 13, 2016 @ 13:56
    Markus Johansson
    0

    Just to follow up - this worked great =D

    response.Headers["SEOCheckerIgnore404Request"] = "true";
    

    // m

Please Sign in or register to post replies

Write your reply to:

Draft