Copied to clipboard

Flag this post as spam?

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


  • Jesper Ordrup 1019 posts 1528 karma points MVP
    Feb 19, 2013 @ 10:30
    Jesper Ordrup
    0

    Wildcard handlers and 404 redirects

    Hi all,

    I've got a 4.8 website running in integrated mode on a Win 08 R2. I want to do some 301 redirects on .html requests but I've run in to some trouble. Heres what I did.

    1) Added a http handler wildcard (*, point to 64 bit aspnet_isapi)

    Result: Standard IIS 7 404 error message.

    2) Added  <httpErrors existingResponse="PassThrough"  />

    Result: While getting rid of standard error, now my site accepts any .html request without any error at all.. Just serves a blank html page..

    3) Added http://our.umbraco.org/projects/developer-tools/301-url-tracker and set it up to handle some tests like /fish.html 

    Result: Same as after 2)

     

    Any clues?

    best

    Jesper

  • Stefan Kip 1614 posts 4131 karma points c-trib
    Feb 19, 2013 @ 11:08
    Stefan Kip
    0

    Yes, umbraco doesn't handle requests other than *.aspx and directory URL's, so the 301 URL Tracker isn't receiving the request.

  • Jesper Ordrup 1019 posts 1528 karma points MVP
    Feb 19, 2013 @ 11:23
    Jesper Ordrup
    0

    Thanks for responding.

    I just thought that I pointed .html to aspnet_isapi and that's where you're handler might catch it - but your answer says that the package work in Umbraco context, only handling what hits Umbraco and not the website aspnet context. 

    Any pointers? UrlRewriting? Another package?

    Sidenode - I still think it's odd that any .html page request comes up blank.

    Thx,
    Jesper 

  • Stefan Kip 1614 posts 4131 karma points c-trib
    Feb 19, 2013 @ 11:31
    Stefan Kip
    1

    http://our.umbraco.org/projects/developer-tools/301-url-tracker/bug-reports/19029-Getting-InfoCasters-301-URL-Tracker-to-handle-starhtml-extensions- 

    I'm also going to work with Lee Messenger to create a nicer version of the 301 URL Tracker, which likely will work through an HttpModule instead of 404handlers, so it's not dependent on umbraco anymore.

     

     

     

     

  • Jesper Ordrup 1019 posts 1528 karma points MVP
    Feb 19, 2013 @ 11:36
    Jesper Ordrup
    0

    Thanks again. That pointed me to the solution. Here's the two rewrites:

           <add name="html"
                   redirect="Domain"
                   ignoreCase="true" rewriteUrlParameter="IncludeQueryStringForRewrite"
                   virtualUrl="(.*)\.html"
                   redirectMode="Permanent"
                   destinationUrl="$1.aspx" />
            <add name="htm"
                   redirect="Domain"
                   ignoreCase="true" rewriteUrlParameter="IncludeQueryStringForRewrite"
                   virtualUrl="(.*)\.htm"
                   redirectMode="Permanent"
                   destinationUrl="$1.aspx" />
  • Jesper Ordrup 1019 posts 1528 karma points MVP
    Feb 19, 2013 @ 11:44
    Jesper Ordrup
    0

    quick note related to if you use the 301 tracker .. when adding custom redirects you need to change the extension to .aspx like this:

    Old page url you want to catch
    /whatever.html

    Add the following to 301 tracker in stead:
    /whatever.aspx

    This will serve your whatever.html

    This I guess results in double 301 - if anyone has any comments on that I'm all ears.

    Thx
    Jesper 

     

  • Stefan Kip 1614 posts 4131 karma points c-trib
    Feb 19, 2013 @ 11:48
    Stefan Kip
    1

    You should do a rewrite, not redirect (rewrite .html to .aspx) and then give the 301 response via the URL Tracker, so it will give 301 on the original request.

    Also you can combine the two rules you've created by using this as the virtualUrl: "(.+)\.html?"

  • Jesper Ordrup 1019 posts 1528 karma points MVP
    Feb 19, 2013 @ 11:51
    Jesper Ordrup
    0

    Sure U mean virtualUrl: "(.+)\.html?"

    and not  virtualUrl: "(.+)\.htm?"

    (I'm officially declaring myself incompatible with regexp :)

  • Stefan Kip 1614 posts 4131 karma points c-trib
    Feb 19, 2013 @ 12:00
    Stefan Kip
    100

    Sorry, I'm not following you?

    I guess this is the rule you need:

    <add name="htm and html to aspx"
    ignoreCase="true"
    rewriteUrlParameter="IncludeQueryStringForRewrite"
    redirect="None"
    virtualUrl="(.+)\.html?"
    destinationUrl="$1.aspx" />

     Though I'm not really experienced with UrlRewriting.NET, I always use the IIS UrlRewrite module.

  • Jesper Ordrup 1019 posts 1528 karma points MVP
    Feb 19, 2013 @ 12:03
    Jesper Ordrup
    0

    Thanks for your time. It was just that I saw the HTML in the virtualUrl="(.+)\.html?" - and that looks like it only hits the .html extension and ? is the joker for 1 char right?

    I'm just gonna try :-)

    Jesper

  • Stefan Kip 1614 posts 4131 karma points c-trib
    Feb 19, 2013 @ 12:04
  • Jesper Ordrup 1019 posts 1528 karma points MVP
    Feb 19, 2013 @ 12:07
    Jesper Ordrup
    0

    Ohh thankx - now I see it .. 

Please Sign in or register to post replies

Write your reply to:

Draft