Help with regex...

Discussion in 'PHP' started by jackslounge, Aug 5, 2008.

  1. #1
    Hi all,

    I am trying to set up a redirect in wordpress (using redirection plugin).

    The source URL that I am redirecting from is in the format:

    www.site.com/concerts/concert-name/
    Code (markup):
    And I am redirecting to

    www.site.com/concerts/concert-name/concert/
    Code (markup):
    Basic rule is that if url contains "/concerts/" and ends with "/concert-name", then add "/concert" to the end of the url.

    I realise that this is messy, it is a temporary solution :)
     
    jackslounge, Aug 5, 2008 IP
  2. nosleepno

    nosleepno Peon

    Messages:
    202
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    $concerts = "www.site.com/concerts/concert-name/";
    if (preg_match("/concerts/i",$concerts)){
    $concerts = $concerts . "concerts/";
    }
    Code (markup):
     
    nosleepno, Aug 5, 2008 IP