Copied to clipboard

Flag this post as spam?

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


  • Heather Floyd 610 posts 1033 karma points MVP 7x c-trib
    Jul 28, 2010 @ 19:04
    Heather Floyd
    0

    Will switching "useDirectoryUrls" to TRUE break incoming links?

    Hi all,

    So, I have been thinking that I'd like to switch the webconfig setting "useDirectoryUrls" to true for my site, to remove those pesky ".aspx" extensions, but I am concerned about all the external links coming into my site from different locations...

    Will all those links now result in a 404 error?

    Or will umbraco automatically chop off the ".aspx" and thus properly redirect them?

    Or do I need to add some custom "urlrewriting" code to make this happen?

    I'd just like to get an idea about what I'm in for if I make the change.

    Thanks!

    Heather

  • Matt Brailsford 4125 posts 22224 karma points MVP 9x c-trib
    Jul 28, 2010 @ 19:08
    Matt Brailsford
    1

    Hi Heather,

    Your URLs will continue to work with the .aspx extention, so you won't get any broken links, but you may want to think about implementing a UrlRewrite rule to do a 301 redirect to the extentionless url, so that search engines don't see it as duplicate content.

    Matt

  • Heather Floyd 610 posts 1033 karma points MVP 7x c-trib
    Jul 28, 2010 @ 19:38
    Heather Floyd
    0

    Thanks, Matt, for your quick response and your suggestion for the redirect code.

    A search in the forum turned up

    http://our.umbraco.org/forum/using/ui-questions/5255-301-redirect-options

    which might help me figure that out.

    Have a great day!

    Heather

  • Heather Floyd 610 posts 1033 karma points MVP 7x c-trib
    Jul 28, 2010 @ 22:18
    Heather Floyd
    0

    Hmm... This is proving more challenging than I expected...

    My RegEx skills are not the best, and I am wondering how I can make this work for all my current pages without hosing the whole site...

    My first attempt is this:

        
            redirectMode="Permanent"
            redirect="Application"
            ignoreCase="true"
            rewriteUrlParameter="IncludeQueryStringForRewrite"
            virtualUrl="~\/*()\.aspx"
            destinationUrl="$1" />

    "\/*()\.aspx" matches all the pages in the site, though, including "/umbraco/" and other "reserved" dirs.

    Does anyone know how to write the regex properly?

    Thanks!

    Heather

  • Paul Blair 466 posts 731 karma points
    Jul 28, 2010 @ 23:10
    Paul Blair
    0

    Hi,

    I think it would be something like this:

       <add name="addWWWtoURL"
             virtualUrl="(.*)://sitename.co.nz/(.*).aspx"
             rewriteUrlParameter="IncludeQueryStringForRewrite"
             destinationUrl="$1://www.sitename.co.nz/$2"
             ignoreCase="true"
             redirect="Domain"
             redirectMode="Permanent" />

     

  • Matt Brailsford 4125 posts 22224 karma points MVP 9x c-trib
    Jul 28, 2010 @ 23:20
    Matt Brailsford
    0

    Hi Heather,

    I reckon something like this should do the trick

       <add name="toExtensionless"
             
    virtualUrl="^~/(.*).aspx(.*)"
             
    rewriteUrlParameter="IncludeQueryStringForRewrite"
             
    destinationUrl="~/$1/$2"
             
    ignoreCase="true"
             
    redirect="Application"
             
    redirectMode="Permanent" />

    Matt

  • Sascha Wolter 615 posts 1101 karma points
    Jul 28, 2010 @ 23:30
    Sascha Wolter
    1

    Hi Heather,

    that's indeed a bit tricky, I came up with the following regex:

    virtualUrl="^\/(?!(umbraco\/|data\/))(?<url>.*)\.aspx"

    And then

    destinationUrl="${url}"

    (Or do not use the named reference ?<url> and use $2 here.)

    So basically take everything that starts at the root of the website with a '/', ends in '.aspx' and doesn't start after the slash with 'umbraco/' or 'data/' etc. Obviously you can get more specific but that should do the trick.

    Hope it works,

    Sascha

  • Heather Floyd 610 posts 1033 karma points MVP 7x c-trib
    Jul 29, 2010 @ 05:08
    Heather Floyd
    0

    Thanks to everyone for your replies. It looks like Sascha's is the closest to what I need, but when I used it with your named reference, there was an error message:

    Parser Error Message: '<', hexadecimal value 0x3C, is an invalid attribute character. Line 40, position 90.

    So, I made some changes... and have this:

    <add name="301RedirectDirUrls"
            redirectMode="Permanent"
            redirect="Application"
            ignoreCase="true"
            rewriteUrlParameter="IncludeQueryStringForRewrite"
            virtualUrl="^\/(?!(umbraco\/|data\/|install\/|usercontrols\/|umbraco_client\/))(.*)\.aspx"
            destinationUrl="$1/$2" />

    Which seems to do the redirecting properly now. (Yay!)

    Now what I'd like to know is how can I verify that this is sending the proper "Permanent Redirect" message to Google? In another threa someone mentioned using Firebug to check, but I can't see where that information would be displayed.

    Does anyone know how I can test this?

    ~Heather

  • Sebastiaan Janssen 5061 posts 15544 karma points MVP admin hq
    Jul 29, 2010 @ 07:22
    Sebastiaan Janssen
    0

    The easiest way to test this has always been Fiddler for me, it has a huge amount of information and it can look a bit daunting at first, but it's such a great and powerful tool.

  • Matt Brailsford 4125 posts 22224 karma points MVP 9x c-trib
    Jul 29, 2010 @ 09:16
    Matt Brailsford
    0

    Hey Heather,

    As sebastiaan says, Fiddler is a good free option, or if you don't mind a small charge you could also try Charles. Both pretty much do the same though.

    Matt

  • Sascha Wolter 615 posts 1101 karma points
    Jul 29, 2010 @ 10:33
    Sascha Wolter
    0

    I think you can also check this with Firebug, in the .Net tab: all connections made are listed and the status as well.

    +1 for Fiddler though as well, awesome tool. :)

  • Heather Floyd 610 posts 1033 karma points MVP 7x c-trib
    Jul 29, 2010 @ 17:47
    Heather Floyd
    0

    Thanks everyone!

    I found the "status" under the .Net tab in Firebug as Sascha suggested (had to click "All") and it said "301 Moved Permanently"

    Success!

    ~Heather

  • Heather Floyd 610 posts 1033 karma points MVP 7x c-trib
    Jul 29, 2010 @ 18:12
    Heather Floyd
    2

    I added a wiki page with this for anyone who might want to do the same thing:

    http://our.umbraco.org/wiki/how-tos/how-to-switch-your-site-to-usedirectoryurls=true-when-it-was-previously-=false

    ~Heather

  • Matt Brailsford 4125 posts 22224 karma points MVP 9x c-trib
    Jul 29, 2010 @ 18:28
    Matt Brailsford
    0

    Awesome,

    Great work.

    Matt

  • Danny Leech 36 posts 114 karma points
    Nov 18, 2011 @ 13:54
    Danny Leech
    0

    This is exactly what I have been looking for - found it at last! Thank you Matt - and Heather for the wiki entry. When I initially tried this I had redirect set to "domain", which stopped this working, took me a while to spot the difference... doh

    Thanks again!

    Dan

  • Heather Floyd 610 posts 1033 karma points MVP 7x c-trib
    Nov 18, 2011 @ 20:19
    Heather Floyd
    0

    Always glad to help, Dan - and welcome to the community!

    ~Heather

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies