Copied to clipboard

Flag this post as spam?

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


  • Henrik Vincent 122 posts 616 karma points
    Nov 02, 2015 @ 08:07
    Henrik Vincent
    0

    redirect URL's with special characters

    Hi there

    As the title implies, I'm trying to find a workaround for redirecting URL's with special characters like commas.

    Some months ago I migrated some old Umbraco 4 site to a new Umbraco 7 installation.

    And now a bunch of our ol URL's ain't working no more, since Umbraco 7 ain't allowing commas in URL's.

    I edited

    So I want to ask you guys, if you've come across a fix to redirect all URL's with i.e. commas to their respective new URL's without the commas.

    Example: http://www.firmabeskrivelser.dk/byggemarked-og-vvs/pergo-laminatgulv,-massivt-traegulv-og-mange-andre-gulvtyper/

    should now redirct to

    http://www.firmabeskrivelser.dk/byggemarked-og-vvs/pergo-laminatgulv-massivt-traegulv-og-mange-andre-gulvtyper/

    The thing is that this site alone has like 3000-4000 posts, so changing them manually isn't an option.

    Hope you can help me out here.

    Kind regards Henrik

  • Mike Chambers 635 posts 1252 karma points c-trib
    Nov 02, 2015 @ 11:14
    Mike Chambers
    1

    if you have access to urlrewrite on your hosting platform then you can use that. or there is the urlrewriting.net component in umbraco http://wondergrub.com/articles/an-introduction-to-umbraco-urlrewriting/

    something like this for urlrewrite in the web.config should cover 2 commas in the url, extend if you expect more.

    <system.webServer>
    <rewrite>
          <rules>
                    <rule name="test" stopProcessing="true">
                        <match url="^([^,]*)[,]*([^,]*)[,]*(.*)$" />
                        <action type="Redirect" url="{R:1}{R:2}{R:3}" />
                    </rule>
          </rules>
        </rewrite>
      </system.webServer>
    
  • Henrik Vincent 122 posts 616 karma points
    Nov 04, 2015 @ 09:30
    Henrik Vincent
    0

    Hi Mike

    Thanks for your reply.

    Your snippet seems to be removing commas from the URL's as intended, but on the same time, the rule seems to be making a redirect loop, which results in the page not being accessible.

    Is this something you've experienced before?

    I tried adding the

    <rewrite>
          <rules>
                    <rule name="test" stopProcessing="true">
                        <match url="^([^,]*)[,]*([^,]*)[,]*(.*)$" />
                        <action type="Redirect" url="{R:1}{R:2}{R:3}" />
                    </rule>
          </rules>
        </rewrite>
    

    after

    But regardless of the sections position, it's causing a redirect loop.

  • Mike Chambers 635 posts 1252 karma points c-trib
    Nov 05, 2015 @ 14:28
    Mike Chambers
    100

    sorry, hadn't actually tested it :-(

    might need that first [,]* changing to a ,

    <match url="^([^,]*),([^,]*)[,]*(.*)$" />
    

    think the redirect loop is that it will match for urls with no commas too.. so changing that first one.. will mean only matches urls with at least one ,

    If that's not it let me know.. then I'll check on a live environment.

  • Henrik Vincent 122 posts 616 karma points
    Nov 06, 2015 @ 13:13
    Henrik Vincent
    0

    Thank you very much, Mike!

    You saved my day :)

    Works like a charm

  • stevejack 3 posts 73 karma points
    Jan 17, 2018 @ 10:57
    stevejack
    0

    I also have some queries about the web.config redirection

    i need to redirect

    www.abc.com.au/"

    to

    www.abc.com.au

  • Sumesh KP 34 posts 107 karma points c-trib
    Jan 22, 2018 @ 11:48
Please Sign in or register to post replies

Write your reply to:

Draft