find and replace external (off site) links.

Discussion in 'PHP' started by eyes_drinker, Dec 26, 2009.

  1. #1
    Hello,

    I need help to find the external links from given string and then replace it using RegExp.

    e.g. my domain is abc.com

    and i want that from the given string any external link should be replaced like ... abc.com/rediector.php?id=externalURL

    any help will be highly appreciated.
     
    eyes_drinker, Dec 26, 2009 IP
  2. gaven

    gaven Peon

    Messages:
    46
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    i think that external url is not going to be same in all the case.
    any way please have look into str_replace

    It could help else you will need regular expression.

    If url is going to be dynamic,you can use some php url filter functions to extract url
    then match it against your url,
    if it doesnt match replace it with your url.
     
    gaven, Dec 27, 2009 IP
  3. eyes_drinker

    eyes_drinker Member

    Messages:
    224
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    26
    #3
    thanks for you reply, str_replace not gonna to be work...

    i need regex to do it all at once, i am trying to do it... if i be successful , i will post it here too, in the mean time any help will be appreciated
     
    eyes_drinker, Dec 27, 2009 IP
  4. HuggyStudios

    HuggyStudios Well-Known Member

    Messages:
    724
    Likes Received:
    20
    Best Answers:
    26
    Trophy Points:
    165
    #4
    Im sure you can do that with modrewrite.
     
    HuggyStudios, Dec 27, 2009 IP