[resolved] Redirection plugin and regular expressions (3 posts)

  1. Mark Ratledge
    Forum Moderator
    Posted 4 years ago #

    Is there anyone good with regular expressions used by the Redirection plugin http://urbangiraffe.com/plugins/redirection/ who can show me what to use in order to redirect all URLs from a folder to the domain root?

    I.e., an page in in /oldsite/ like /oldsite/this-is-my-page.html, /oldsite/this-is-my-page-too.html, etc., needs to go to root via a regular expression.

    This doesn't want to work:

    Source: ^oldsite/(.*)
    Target: http://mydomain.com
  2. Paul Vickery
    Posted 4 years ago #

    I think your problem could be that you are trying to match "^oldsite/(.*)" rather than "^/oldsite/(.*)". I don't bother using ^ in my matches though.

    Also, you may find it useful to include the actual old page in the new url as a query string, as you've tagged it, something like:


    You can then see your redirections in Google analytics etc.

    So try:

    Source: ^/oldsite/(.*)
    Target: http://mydomain.com/?redir=$1

    I found a really nice regex cheat sheet the other day at http://www.addedbytes.com/cheat-sheets/regular-expressions-cheat-sheet/ so it might be worth you printing that out, and experimenting!

  3. Mark Ratledge
    Forum Moderator
    Posted 4 years ago #

    Thanks, was able to get it to work with:

    Source: /oldsite/(.*)
    Target:  http://mydomain.com

    The extra RegEx in the target resulted in keeping the old URL in the browser bar for some reason.

Topic Closed

This topic has been closed to new replies.

About this Topic