Help with Regex in Redirection (8 posts)

  1. jonmrich
    Posted 4 years ago #

    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: http://www.doseofdigital.com/2011/10/fa..

    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?



  2. @danomak
    Posted 4 years ago #

    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.

  3. openmtl
    Posted 4 years ago #

    Maybe a regex like this...


  4. jonmrich
    Posted 4 years ago #

    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.


  5. jonmrich
    Posted 4 years ago #


    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: http://www.doseofdigital.com/2009/12/monitoring-adverse-events-social-media-pharmas-biggest-brands/?utm_medium=bt.io-twitter&utm_source=twitter.com&utm_content=backtype-tweetcount

    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.

  6. stevemagruder
    Posted 4 years ago #

    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>'.

  7. Gabe462
    Posted 4 years ago #

    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 ?

  8. Gabe462
    Posted 4 years ago #

    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


Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Redirection
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic