Copied to clipboard

Flag this post as spam?

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

  • Greg Berlin 818 posts 634 karma points
    Jun 29, 2009 @ 10:27
    Greg Berlin

    Using UrlRewriting to redirect domain

    hey all,

    I need to setup some redirections on a website, as follows: > >

    Basically is the live website, and all other domains should redirect to this one (using 301 permanent redirect for SEO purposes)

    I have discovered that the engine is already used by Umbraco, so this is the natural choice of rewriting engines to use.. i'm just wondering if anybody has written a regular expression to do what i need (change the domain name, keep the rest of the url the same)?

    And if that somebody has it setup in a rewrite rule in UrlRewriting.config and can provide the whole rule, that'd be even more supremo.

    Thanks heaps


    ps: Site is running Umbraco 3.0.5 - if i upgrade to v4.0, are there any changes required for the rewriting rules?

  • Shannon Deminick 1523 posts 5250 karma points MVP
    Jun 29, 2009 @ 10:47
    Shannon Deminick

    Documentation can be found here:


    You'll need to setup a domain redirect such as:

    <add name="asdfasdf"  
               ignoreCase="true" rewriteUrlParameter="IncludeQueryStringForRewrite"




    With domain redirects, you need to include the http:// syntax for your Urls.

  • Greg Berlin 818 posts 634 karma points
    Jun 29, 2009 @ 11:05
    Greg Berlin

    Thanks Shannon, but that didn't work for me... i get this error:

    any ideas why?

    Line 34:            ignoreCase="true" rewriteUrlParameter="IncludeQueryStringForRewrite"
    Line 35: virtualUrl="*)
    <span style="color: red;">Line 36: destinationUrl="$1"
    </span>Line 37: redirectMode="Permanent"
    Line 38:

  • Greg Berlin 818 posts 634 karma points
    Jun 29, 2009 @ 11:08
    Greg Berlin

    damn... the pasted error looked great in the edit window, but got mangled in the display... anyway, you can still get the idea.

    i noticed in the documentation it says this:


      regular expression replacement term

      A regular expression term describing the target page (physical file)


    Does this mean it requires a path to a physical file?  if so, how would i get it to change the actual domain its redirecting to?

  • Shannon Deminick 1523 posts 5250 karma points MVP
    Jun 29, 2009 @ 23:03
    Shannon Deminick

    Doh! sorry, what i posted is missing a closing quotation mark, I had:


    originally, but you need:


    This is why your getting a config error.

    No need for physical files to exist, however, are you running IIS 6 or IIS 7? If you are running IIS 6, then you'll also need to add a wildcard mapping to the aspnet isapi DLL. Of the top of my head, you need to go to the home tab for your IIS website, click configuration and in the bottom of the window there's an area that says wildcard mapping. You need to add a reference to aspnet_isapi.dll (or something ... ) from your windows/ .net version)... and make sure your set the checkbox correctly so that it doesn't verify that the file exists (otherwise, you would need a real file). IIS 7 doesn't need to use wildcard mappings.

    Hope this helps!

  • Greg Berlin 818 posts 634 karma points
    Jul 01, 2009 @ 13:59
    Greg Berlin

    Thats weird... i fixed the problem almost right away, and came back and said that it was cos of the missing quotation mark.. but that post got lost somehow.  hmmmm... this forum is cool, but definitely still a little quirky.

  • Chief 24 posts 45 karma points
    Sep 23, 2009 @ 08:51

    Your example above return a 302 - which is not good ?

    I have succeeded in UrlRewriting.config (/config/UrlRewriting.config) to achieve a clean 301 - Example below:

        <add name="just-a-name-fo-you-know-which-one"  
       ignoreCase="true" rewriteUrlParameter="IncludeQueryStringForRewrite"
       destinationUrl="" />


  • Søren Linaa 255 posts 208 karma points
    Oct 01, 2009 @ 14:46
    Søren Linaa

    Just to sum up so everybody gets it right. All credits goes to the members above.

    This 301 redirect vil make your site go from to (without www), so the search engines only will crawl one domain and avoid double content.


    Edit: UrlRewriting.config (/config/UrlRewriting.config)

    <urlrewritingnet xmlns="">
        <add name="Your-name"
       ignoreCase="true" rewriteUrlParameter="IncludeQueryStringForRewrite"
       destinationUrl="$1" />


    Cheers !

  • Asger 25 posts 171 karma points
    Jul 27, 2016 @ 10:49

    Hi Søren.

    Im trying to deal with the same issue, however im not sure which part of your code i need to fill out with my own data, and with what.

    Could you make that more clear to help me out? :) Basically all i want is that my webpage never uses www in the url.


  • Ryan 24 posts 106 karma points
    May 03, 2017 @ 00:45

    It took me quite some time to figure out I can only link one domain to another domain, not a route to another domain, for anyone reading...

Please Sign in or register to post replies

Write your reply to: