Copied to clipboard

Flag this post as spam?

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


  • Bo Damgaard Mortensen 719 posts 1207 karma points
    Jun 24, 2012 @ 17:26
    Bo Damgaard Mortensen
    0

    301 redirect mappings on a node

    Hi all,

    I'm in a situation where the client want's to set up 301 redirects on their new site. This s easily done with the great 301 URL tracker package, but I simply can't get it to work the way I want :-(

    Thing is, the client have 1600+ urls from their old site that they want to set up 301 redirects for on their new site. Since their old site was a Joomla site, the old URLs are .php, .html .cfm etc etc. I've searched high and low on this since I don't want to manually add all these redirects in the UrlRewriting.config file ;-) I've found this snippet by browsing the forums:

    <add name="phprewrite"
         virtualUrl="^~/(.*).php"
         rewriteUrlParameter="ExcludeFromClientQueryString"
         destinationUrl="~/$1.aspx"
         ignoreCase="true" />

    While this works this way:

    When I select the node in Umbraco "Om os" (About us in danish) and I enter the following url: "/about.php" it redirects me to the page "/about.aspx" which doesn't exists since there's no Umbraco node with that name.

    Is there a way to make it redirect to the selected node for the rule instead? That'll make my life much easier ;-)

    Thanks a lot in advance.

    All the best,

    Bo

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Jun 24, 2012 @ 22:08
    Jeroen Breuer
    0

    Hmm not sure if that is possible. Might be better to write a custom piece of code for that. Can you give an example where the page should redirect to. For example you say /about.php becomes /about.aspx, but that does't exist. What is the name or id of the node which it should redirect to?

    Jeroen

  • Bo Damgaard Mortensen 719 posts 1207 karma points
    Jun 24, 2012 @ 22:16
    Bo Damgaard Mortensen
    0

    Hi Jeroen,

    Thanks a lot for your input :-) Greatly appreciated!

    I hit the nail on the head and started building my own datatype which modifies the UrlRewriting.config directly from a node (don't know if that will cause any problems?) and the ability to add more rules for the node you're editing. 

    Got it to write to the config now, so far so good ;-) I wonder if there's a place for a package like this, maybe? I can't be the only one who have had this need, no?

    Thanks again!

    - Bo

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Jun 24, 2012 @ 22:19
    Jeroen Breuer
    0

    So far I've used the Config Tree package so I can edit the redirects from Umbraco, but your package sounds like a much better solution :).

    Jeroen

  • Bo Damgaard Mortensen 719 posts 1207 karma points
    Jun 24, 2012 @ 22:21
    Bo Damgaard Mortensen
    0

    Oh by the way, I totally forgot to answer your question - sorry about that.

    Let's just grab the "about us" example. If I pick the Umbraco node "Om os" in the 301 Url Tracker and enter the old url: "/about.php" with the rewrite rule I mentioned in my original post, it will try to redirect me to "/about.aspx" since it's just looking at the extension :-)

    Dunno if that makes any sense?

  • Bo Damgaard Mortensen 719 posts 1207 karma points
    Jun 24, 2012 @ 22:23
    Bo Damgaard Mortensen
    0

    I agree that you could also just use the config tree package, but I don't want the client to be able to enter the actual XML for the config (you just never know, right? ;-))

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Jun 24, 2012 @ 22:33
    Jeroen Breuer
    0

    About your example I know it will try to redirect to /about.aspx, but what url should it redirect to instead?

    Jeroen

  • Bo Damgaard Mortensen 719 posts 1207 karma points
    Jun 24, 2012 @ 22:40
    Bo Damgaard Mortensen
    0

    It should redirect to the Umbraco node you select when creating a new 301 URL Tracker node :-) So basically you'd say:

    Make a 301 redirect *from* an old url (the URLs you enter in the 301 redirected UI) to *this* node (the selected node)

    It could also be that I'm totally confused about how the 301 URL tracker works, though.

    Let me know if this is totally off ;-)

     

Please Sign in or register to post replies

Write your reply to:

Draft