WordPress.org

Support

Support » Plugins and Hacks » [Resolved] Redirection plugin and regular expressions

[Resolved] Redirection plugin and regular expressions

  • Mark Ratledge

    @songdogtech

    Forum Moderator

    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
Viewing 2 replies - 1 through 2 (of 2 total)
  • Paul Vickery

    @paul-vickery

    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:

    http://mydomain.com/?redir=$1

    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!

    Moderator Mark Ratledge

    @songdogtech

    Forum Moderator

    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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] Redirection plugin and regular expressions’ is closed to new replies.