Copied to clipboard

Flag this post as spam?

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


  • pnr 131 posts 226 karma points
    May 30, 2010 @ 08:27
    pnr
    0

    UrlRewriting is redirecting to default.aspx insted of /

    I have setup som rules for UrlRewriting in urlrewriting.config, my problem is that it redirect to default.aspx insted of just /. When the rule is not used the client see the url www.example.com/, when the rule is used it redirect to www.exaple.com/default.aspx.

    How can i setup the rule to redirect to the root without default.aspx?

    my rule is as follows:

    <add name="example"      virtualUrl="http\://example.dk"         rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="http://www.example.dk" redirect="Domain" redirectMode="Permanent" ignoreCase="true" />

     

    thanks in advance

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    May 30, 2010 @ 12:47
    Morten Bock
    1

    I have a domain rewrite like this:

    <add name="domainRewrite"
                virtualUrl="http://example.com/(.*)"
                rewriteUrlParameter="ExcludeFromClientQueryString"
                destinationUrl="http://www.example.com/$1"
    redirect="Domain" redirectMode="Permanent" ignoreCase="true" />

    This takes any request to htttp://example.com type urls, and redirects to the same page just with a www. in fornt.

    Does that answer your question?

  • jonok 297 posts 658 karma points
    May 31, 2010 @ 07:53
    jonok
    0

    In the urlrewriting.config in the urlrewritingnet section tag have you got a defaultPage set? I was having the same problem as you and then I removed the defaultPage from the tag - this worked on my VPS which is running IIS6, it didnt work on my local machine which runs IIS7.

  • pnr 131 posts 226 karma points
    May 31, 2010 @ 20:33
    pnr
    0

    Thanks a lot for your reply's!

    Morten: your surgestion is almost working, it works fine if i redirect from the a domain with our www to the same domain with www. But if i try to redirect from another domain, it isn't working. But the this is working (i removed the "$1" in destinationUrl):

     

    <add name="domainRewrite"
               
    virtualUrl="http://example.com/(.*)"
               
    rewriteUrlParameter="ExcludeFromClientQueryString"
               
    destinationUrl="http://www.example.com"
               
    redirect="Domain"
               
    redirectMode="Permanent"
               
    ignoreCase="true" />

    Strange or what?

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    May 31, 2010 @ 22:08
    Morten Bock
    0

    Hmm, I am not sure what you are trying to do. You want to redirect from one domain to another, preserving the url? Could you give an example of the url that the user visits, and the url you want him to be ridirected to?

  • pnr 131 posts 226 karma points
    Jun 01, 2010 @ 07:54
    pnr
    0

    Hi Morten and thanks for your reply!

    If I do like underneath, and type "myfirstdomain.com" in the browser, I get "www.myseconddomain.com/Default.aspx". If i remove $1 from the destinationUrl it redirect to "www.myseconddomain.com".

    <add name="domainRewrite"
               
    virtualUrl="http://myfirstdomain.com/(.*)"
               
    rewriteUrlParameter="ExcludeFromClientQueryString"
               
    destinationUrl="http://www.myseconddomain.com/$1"
               
    redirect="Domain"
               
    redirectMode="Permanent"
               
    ignoreCase="true" />
  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    Jun 01, 2010 @ 09:54
    Morten Bock
    0

    Hmm, sounds a bit strange, but maybe this could be a workaround.

    Since the urlRewriting works with "first match" principle, you could make three rules. 

    <add name="domainRewriteClean"
                virtualUrl="http://myfirstdomain.com/"
                rewriteUrlParameter="ExcludeFromClientQueryString"
                destinationUrl="http://www.myseconddomain.com/"
                redirect="Domain"
                redirectMode="Permanent"
                ignoreCase="true" />
    
    <add name="domainRewriteDefault"
                virtualUrl="http://myfirstdomain.com/Default.aspx"
                rewriteUrlParameter="ExcludeFromClientQueryString"
                destinationUrl="http://www.myseconddomain.com/"
                redirect="Domain"
                redirectMode="Permanent"
                ignoreCase="true" />
    
    <add name="domainRewrite"
                virtualUrl="http://myfirstdomain.com/(.*)"
                rewriteUrlParameter="ExcludeFromClientQueryString"
                destinationUrl="http://www.myseconddomain.com/$1"
                redirect="Domain"
                redirectMode="Permanent"
                ignoreCase="true" />         

    The first two would try to match urls that should go to the root of the second domain, and the third one would catch any other content urls the browser would request.

  • psiho 101 posts 96 karma points
    Nov 09, 2010 @ 15:00
    psiho
    0

    I'm bumping this up as I have same problem:

    <add name="example"
        redirect="Domain"
        ignoreCase="true"
        virtualUrl="http://example\.com"
        redirectMode="Permanent"
        destinationUrl="http://www.example.com" />

    It correctly works for every page but home page where it appends /Default.aspx. So, going to example.com/somepage.aspx correctly redirects to www.example.com/somepage.aspx

    ... but... going to example.com redirects to www.example.com/Default.aspx and I really do not want Default.aspx at the end. I did not try to write 2 rules for it, suggested in previous post as it seems to me like multiple 301 redirects in case where I redirect another domain to this one (which i do) so I would get: example2.com -> www.example.com/Default.aspx -> www.example.com

    There must be a better way.

    DefaultPage parameter is not in my urlrewrite.config but if I put it there myself it changes nothing.

  • Petr Snobelt 923 posts 1535 karma points
    Jan 05, 2011 @ 23:14
    Petr Snobelt
    0

    Hi I have same problem, it redirects to default.aspx instead of /

    Only working solution is Morten's workaround,

    Is there anyone, who solved it in better way? 

  • Thomas Egebrand Gram 63 posts 138 karma points
    Jan 27, 2011 @ 16:45
    Thomas Egebrand Gram
    0

    As i've discovered so far, Mortens workaround doesn't seem to work in Umbraco v 4.5.2

    I've tried to add the rules to the UrlRewriting.config - but it still only rewrites from non-www to www.

    Sadly, when it redirects from http://mysite.com to http://www.mysite.com it also adds /default.aspx - as some of the others here.

    What i've gathered from a few hours of knocking my head against the wall finding a solution - is that the windows server (the ISS) somehow supports a "default" file, which could seem to be the root of all evil with this default.aspx?

    For SEO reasons i cannot have /default.aspx or /frontpage.aspx - i just want it as a clean www.mysite.com/

    I do not have access to the ISS on my server, but can anyone verify this, or is it all complete jibberish?

    - Thomas Egebrand Gram

  • trfletch 598 posts 604 karma points
    Mar 28, 2011 @ 11:21
    trfletch
    0

    Did anyone resolve this in the end because I have the same problem. I can try Mortons fix because I am running Umbraco 4.5.1 but does it mean that if I upgrade to a later version then the problem is going to return?

  • trfletch 598 posts 604 karma points
    Mar 28, 2011 @ 11:34
    trfletch
    0

    Sorry, please ignore my post, my issue was resolved by removing:

    defaultPage

     

    = "default.aspx"

Please Sign in or register to post replies

Write your reply to:

Draft