Copied to clipboard

Flag this post as spam?

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


  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Aug 22, 2014 @ 10:44
    Jan Skovgaard
    0

    Trimming .aspx urls preserving querystrings

    Hi guys

    I'm currently making sure that if someone would hit a page with a .aspx suffix is 301 redirected to the page without the suffix. So if one would hit

    mysite.com/page.aspx one would be redirected to mysite.com/page

    This is also working fine. However when I hit a page that has a querystring it's not doing the redirect. Say I have this page

    mysite.com/page.aspx?param=true then the redirect does not happen. What I want to see is that I end up here: mysite.com/page?param=true

    I'm using the UrlRewriting.config and I'm using the below rule. I'm not that skilled doing this stuff so any hints are highly appreciated.

        <add name="trim_aspx_from_directory_urls"
             redirect="Application"
             redirectMode="Permanent"
             virtualUrl="^/(?![0-9]+.aspx)(?!umbraco/)(.*).aspx$"
             rewriteUrlParameter="IncludeQueryStringForRewrite"
             destinationUrl="/$1"
             ignoreCase="true" />
    

    Cheers, Jan

  • Fuji Kusaka 2203 posts 4220 karma points
    Aug 22, 2014 @ 12:57
    Fuji Kusaka
    0

    Hi Cheers,

    I have this working for me just try changing 

    rewriteUrlParameter="IncludeQueryStringForRewrite"
    rewriteUrlParameter="ExcludeFromClientQueryString"

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

    //fuji

Please Sign in or register to post replies

Write your reply to:

Draft