Copied to clipboard

Flag this post as spam?

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


  • 9146fan 2 posts 22 karma points
    Jan 26, 2013 @ 01:12
    9146fan
    0

    URLRewriting.net and changing underscore to hyphen

    I'm not a RegEX expert by any means (need to put that on my bucket list).

    The first thing I was able to accomplish was to trim all of my aspx files so that I could useDirectoryURLs all the time.

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

     

    Next, I want to write a set of regex expressions that change underscore (_) to hyphen (-) anywhere it appears in the URL path EXCEPT for the /media folder. I can't get my head around this or how to do it to an unlimited dept in the url path (or say at least 10 folders maximum depth). I want to change underscores to hyphens whether they are in the directory structure or the aspx file name.

    Ex:

    www.domain.com/somedir_fun/otherdir/joe_fred/press_release.aspx

    converts to

    www.domain.com/somedir-fun/otherdir/joe-fred/press-release.aspx

    (note: the converted URL would then likely get converted to a SEO friendly directory url from the rule above.)

     

  • Fuji Kusaka 2203 posts 4220 karma points
    Jan 26, 2013 @ 05:44
    Fuji Kusaka
    0

    If you want to change the way umbraco will write your url you will need to set this in your umbracoSetttings.config file under the config folder.

    <char org=" ">-</char>
Please Sign in or register to post replies

Write your reply to:

Draft