Support » Plugin: Redirection » Help with Regex in Redirection

  • Due to a bunch of spammy web search sites, I’ve got a ton of broken links in my Webmaster tools that I’d like to fix.

    For some reason, these search sites don’t direct to the correct URLs because they all cut off the full URLs by adding “..” (no quotes) to the end of the URL.

    For example: This is a broken (not found) URL that I see in my Webmaster tools:

    I’ve got about 100 of these. They all have the same syntax (site url/year/month/XX..). I tried coming up with a regex expression that would fix this, but I can’t figure it out. Basically, I want every URL that has “..” (no quotes) in it to redirect to the homepage. Only the URLs from these web search sites have the two dots, so no other legit URLs or links should be affected.

    Can someone help with this?


Viewing 7 replies - 1 through 7 (of 7 total)
  • Hey there,

    I’ve only put a few minute of thought into this, but it sounds like you can get what you’re looking for by using this little function in conjunction with some simple regex.

    Maybe a regex like this…


    Thanks for the suggestion…that regex didn’t work

    I tried this and it seems to work. Anyone see any problems with this? Haven’t found any problems this causes anywhere else yet.



    Turns out my regex didn’t work.

    The one I posted above


    redirected all pages that had two dots in the URL no matter where the dots were placed. So, a link like this was incorrectly forwarded:

    I found that this regex worked perfect though, as it only redirected URLs that had two dots in succession.


    I didn’t know the \Q...\E expression option when I suggested my first fix.

    source: \/(.*)\/(.*)\/(.*)\.\.$
    target: <base-url>/$1/$2/$3

    Would this work? The $ at the end means that these are the final characters in the string. I’ve also escaped the forward slashes — perhaps not necessary but it doesn’t hurt. Substitute your base URL for ‘<base-url>’.

    What’s the regex equivelant of ‘*’ ? (the more universal wildcard…). I want to redirect /path/to/anyfilename.php

    what would I use to regex match /path/to/*.php ?

    I found this, which works on a regex test site:


    but it’s not working when I try to use it as the source URL in Redirection. Is this just incorrect?

    it should be able to match


Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Help with Regex in Redirection’ is closed to new replies.