Copied to clipboard

Flag this post as spam?

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


  • Dan 1288 posts 3921 karma points c-trib
    Dec 16, 2009 @ 17:31
    Dan
    0

    301 redirect not doing anything

    Hi,

    I've modifid the URLRewriting.config file in the /config folder, to the following (it's just a simple, single, one-off, hard-coded redirect required):

    <urlrewritingnet xmlns="http://www.urlrewriting.net/schemas/config/2006/07">
    <rewrites>
    <add name="301-redirect-for-old-page"
    redirectMode="Permanent"
    redirect="Domain"
    ignoreCase="true"
    rewriteUrlParameter="IncludeQueryStringForRewrite"
    virtualUrl="http://www.mydomain.com/old/"
    destinationUrl="http://www.mydomain.com/level1/new.aspx" />

    </rewrites>
    </urlrewritingnet>

    However, when I visit the URL, it just takes me to a default 404 error page.  How can I get this working - is the code above wrong or do I need to do something to tell the system to pick up the changes in the config file?  I've modified web.config to try to 'refresh' things but no joy still.

    Any ideas?  Thanks all.

  • bob baty-barr 1180 posts 1294 karma points MVP
    Dec 17, 2009 @ 04:48
    bob baty-barr
    0

    my rules look a bit different...

    <add name="KickIt3"  virtualUrl="^http\://www.baty-barr.com/(.*).aspx"
                    rewriteUrlParameter="IncludeQueryStringForRewrite"
                    destinationUrl="http://baty-barr.com/$1"
                    redirect="Domain"
                    redirectMode="Permanent"
                    ignoreCase="true" />

     

    i am NOT any kind of authority on url rewriting... but the rules i have made all appear to work.

  • Dan 1288 posts 3921 karma points c-trib
    Dec 17, 2009 @ 10:54
    Dan
    0

    Thanks Bob.  I've tried a rule similar to yours and it does work - so it seems as if the config file is active, but whenever I change it to suit my situation it stops working.  I'm also no authority on URL rewriting (clearly :)) but if anyone can shed any light on this I'd be most grateful - surely it's almost there?

    <add name="301-redirect-for-cpd-page"  virtualUrl="^http://www.mydomain.com/old"
    destinationUrl="http://www.mydomain.com/level1/new.aspx"
    redirect="Domain"
    redirectMode="Permanent"
    ignoreCase="true" />

     

     

  • Dan 1288 posts 3921 karma points c-trib
    Dec 17, 2009 @ 15:12
    Dan
    0

    Hmm, failing any direct solutions, is the way Umbraco handles URL rewriting the same as general .NET URL rewriting?  Can I use general .NET documentation for this config setting or is that going to create problems?

    Thanks

  • bob baty-barr 1180 posts 1294 karma points MVP
    Dec 17, 2009 @ 20:30
    bob baty-barr
    0

    techincally, isn't the url going to be /old/something.ext ??? could that be your issue?

  • Yannick Smits 321 posts 718 karma points
    Dec 17, 2009 @ 22:54
    Yannick Smits
    0

    probably the rule isn't firing because your IIS default document isn't set to a document that is handled by the .NET Framework (ie. default.htm). In IIS you can change this and have default.htm also be processed by ASP.NET.

  • Dan 1288 posts 3921 karma points c-trib
    Dec 18, 2009 @ 10:49
    Dan
    0

    @Bob - The link which has been marketed is http://www.mydomain.com/old. ; On the old site (which was static HTML) this would have defaulted to http://www.mydomain.com/old/index.htm.

    @Yannick - How do I get index.htm to be processed by ASP.NET?

    Thanks both.

  • Dan 1288 posts 3921 karma points c-trib
    Dec 18, 2009 @ 10:51
    Dan
    0

    Just to add... on the new site there's no such page as http://www.mydomain.com/old - it's just a virtual URL which needs to redirect to a new, physical URL.

  • Dan 1288 posts 3921 karma points c-trib
    Dec 18, 2009 @ 10:57
    Dan
    1

    Apologies for the scattergun posting, but I've got a little further.  I've changed my rule to:

    <add name="301-redirect-for-cpd-page"  virtualUrl="^http://www.mydomain.com/old/default.aspx"
                                                   
    destinationUrl="http://www.mydomain.com/level1/new.aspx"
                                                   
    redirect="Domain"
                                                   
    redirectMode="Permanent"
                                                   
    ignoreCase="true" />

    And this now works when I enter http://www.mydomain.com/old/default.aspx, but still not when I enter http://www.mydomain.com/old - which is the marketed URL.

    Does anyone know how to get over this final hurdle?

  • Yannick Smits 321 posts 718 karma points
    Dec 18, 2009 @ 10:58
    Yannick Smits
    0

    In IIS go to your application properties, go to "home directory" tab, click configuration, on mappings tab click Add. Then for executable insert:
    C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll
    for Extension insert: .htm

  • Yannick Smits 321 posts 718 karma points
    Dec 18, 2009 @ 11:01
    Yannick Smits
    0

    you might also want to do that for .html

    just in case you have index.html at the top of your default pages (you can also check this in site properties > Documents tab.

  • Dan 1288 posts 3921 karma points c-trib
    Dec 18, 2009 @ 11:33
    Dan
    0

    Thanks Yannick - I'm confused though as there's no HTML page there, so why does this need to be added?

  • Yannick Smits 321 posts 718 karma points
    Dec 18, 2009 @ 11:51
    Yannick Smits
    0

    If you request a directory name IIS will automatically try to find one of your default documents specified in your app settings (as described above). 

    Have you tried this?

    If it doesn't work you might need to map the 404 in App properties > Custom Errors to a (non existing) 404.aspx page which will trigger the .net rewrite rule.

  • Dan 1288 posts 3921 karma points c-trib
    Dec 18, 2009 @ 12:05
    Dan
    0

    I've tried and it doesn't work unfortunately :(.  Who'd have thought it would be so difficult to set up a single 301!?

    So, if I go the 404 route, will that mean that it gets a lot complicated if other 301s have to be created in future?  At the moment the client is only requiring 1 301 redirect, but eventually there could be 100+.

  • Yannick Smits 321 posts 718 karma points
    Dec 18, 2009 @ 12:11
    Yannick Smits
    0

    No, the 404 trick is just to make sure your directory calls get handled by .NET. Only needs to be set once.

  • Dan 1288 posts 3921 karma points c-trib
    Dec 18, 2009 @ 12:18
    Dan
    0

    When I try to edit the 404 'file' in Custom Errors using a non-existent page, it won't let me save because the page doesn't exist.

  • Yannick Smits 321 posts 718 karma points
    Dec 18, 2009 @ 12:23
    Yannick Smits
    0

    Ah, apparently you have to create a 404.aspx first. 

  • Dan 1288 posts 3921 karma points c-trib
    Dec 18, 2009 @ 12:25
    Dan
    0

    Thanks Yannick - I appreciate your patience.

    Do I create the 404 as per any other page through Umbraco, or do I just upload a blank page called 404.aspx to the root of the domain via FTP?

  • Yannick Smits 321 posts 718 karma points
    Dec 18, 2009 @ 12:47
    Yannick Smits
    0

    I guess for IIS to see it you should upload an empty 404.aspx through FTP. hope it works for you!

Please Sign in or register to post replies

Write your reply to:

Draft