Copied to clipboard

Flag this post as spam?

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


  • Anders Brohäll 295 posts 561 karma points c-trib
    Jan 25, 2012 @ 17:13
    Anders Brohäll
    0

    UrlRewritingNet, redirecting foo/bar.aspx to foo/bar/

    Hi,

    I've got a scenario there i want the site to run with umbracoUseDirectoryUrls set to true and redirect all calls to "foo/bar.aspx" to the directory "/foo/bar/".

    I thought i might be able to do it with UrlRewritingNet, setting a rewrite like:

    <add name="aspxToFolder" virtualUrl="(.*).aspx" destinationUrl="~$1/" redirectMode="Permanent" ignoreCase="true" redirect="Application" />

    That will, of course, also redriect all calls to "/umbraco/foo.aspx" to "/umbraco/foo/".

    I've tried all kinds of black magic (reads regular expressions) to exclude "/umbraco/", without success. I cant seem to find the correct expression.

    Also, i've tried to add the attribute rewriteOnlyVirtualUrls to the urlrewritingnet element, setting it to false, but for some reason "/umbraco" seems to be treated as a virtual url, or the parameter just doesnt work.

    How do i make the redirect work?

    Thank you!

  • Stefan Kip 1614 posts 4131 karma points c-trib
    Jan 25, 2012 @ 18:18
    Stefan Kip
    0
    <!-- SEO | Trim .aspx for directory URLs -->
    <!-- Note: using UrlRewriting.Net because IIS UrlRewriting doesn't like rules with .aspx in it -->
    <add name="SEO | Trim .aspx for directory URLs"
    redirect="Application"
    redirectMode="Permanent"
    virtualUrl="^/(?![0-9]+.aspx)(?!umbraco/)([^\?]*?).aspx$"
    rewriteUrlParameter="ExcludeFromClientQueryString"
    destinationUrl="/$1"
    ignoreCase="true" />
  • Anders Brohäll 295 posts 561 karma points c-trib
    Jan 25, 2012 @ 19:18
    Anders Brohäll
    0

    Minor edit: destinationUrl="/$1" should in my case have a tailing slash, destinationUrl="/$1/" (for future reference).

    Excellent, thank you!

  • Stefan Kip 1614 posts 4131 karma points c-trib
    Jan 25, 2012 @ 21:17
    Stefan Kip
    0

    Aight, I'll edit mine too :-) Ty

Please Sign in or register to post replies

Write your reply to:

Draft