Copied to clipboard

Flag this post as spam?

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


  • Jacob Jensen 40 posts 60 karma points
    Aug 17, 2011 @ 17:16
    Jacob Jensen
    0

    urlrewrite, regex help

    Hi.

    Iwe just upgraded a solution from 4.0 to 4.7, the old solution had a rewrite like this:

    <add name="ShopRewrite"
    virtualUrl="^~/(.*)"
    rewriteUrlParameter="ExcludeFromClientQueryString"
    destinationUrl="~/?alias=$1"
    ignoreCase="true" />

     

    The rewrite worked perfectly on the old version, because of the aspx extensions to normal pages, but iwe set

    <add key="umbracoUseDirectoryUrls" value="true" />

    And now the rewrite hits every page :/

    I need the rewrite to take only url without the last "/"

    Ex, i have a page called "frontpage", the url is:

    http://localhost/frontpage/ <- this one should not hit the rewrite

    Further i have 600 shops with an url alias as a property, the url generated is ex:

    http://localhost/spar-aarhus <-- this one should his the rewrite, because of the missing last "/"

    Please tell if u need any more information.

    Thx in advance.
    Jacob.

  • Stefan Kip 1614 posts 4131 karma points c-trib
    Aug 17, 2011 @ 17:28
  • Jacob Jensen 40 posts 60 karma points
    Aug 17, 2011 @ 17:31
    Jacob Jensen
    0

    thx !!!

  • Jacob Jensen 40 posts 60 karma points
    Aug 17, 2011 @ 18:01
    Jacob Jensen
    0

    hey, it seems like it removes the last char:

      <add name="ShopRewrite"
         virtualUrl="^~/(.+)(?:[^/])$"
         rewriteUrlParameter="ExcludeFromClientQueryString"
         destinationUrl="~/?alttemplate=butik&amp;alias=$1"
         ignoreCase="true" />

     

    ex:

    http://localhost/store2 = http://localhost/?alttemplate=butik&store

    if i type

    http://localhost/store2x = http://localhost/?alttemplate=butik&store2

    Do u have a fix ?
    Best regards

    Jacob

  • Stefan Kip 1614 posts 4131 karma points c-trib
    Aug 17, 2011 @ 18:08
    Stefan Kip
    0

    Hmm yes I see, sorry about that.

    Let me take a look and I'll get right back at ya!

  • Jacob Jensen 40 posts 60 karma points
    Aug 17, 2011 @ 18:09
    Jacob Jensen
    0

    np, glad for ur help :) !!

  • Stefan Kip 1614 posts 4131 karma points c-trib
    Aug 17, 2011 @ 18:15
    Stefan Kip
    0

    Sorry, I can't seem to find a 'nice' fix. There's a quickfix though:

    destinationUrl="/?alttemplate=butik&amp;alias=$1$2"

  • Stefan Kip 1614 posts 4131 karma points c-trib
    Aug 17, 2011 @ 18:16
    Stefan Kip
    0

    Oh wait, I made a mistake, this is the quickfix:

      <add name="ShopRewrite"
         virtualUrl="^~/(.+)([^/])$"
         rewriteUrlParameter="ExcludeFromClientQueryString"
         destinationUrl="/?alttemplate=butik&amp;alias=$1$2"
         ignoreCase="true" />

  • Jacob Jensen 40 posts 60 karma points
    Aug 17, 2011 @ 18:28
    Jacob Jensen
    0

    pefect, it works perfectly !..

    thx

  • Jacob Jensen 40 posts 60 karma points
    Aug 18, 2011 @ 13:08
    Jacob Jensen
    0

    Changed to:

     

    <add name="ShopRewrite"
             virtualUrl="^~/(/.+)([^/.])$"
             rewriteUrlParameter="ExcludeFromClientQueryString"
             destinationUrl="/?alttemplate=butik&amp;alias=$1$2"
             ignoreCase="true" />

     

    the other one hit /webresource.axd :)

    /J

Please Sign in or register to post replies

Write your reply to:

Draft