0

When href="something/blah/" I need to add the domain $site/something/blah

When href="/someething/blah" I need to add the domain $site/something/blah

when href="http:// I need to do nothing.

when href="www.blah.com I need to add http://

Updated for more specific situation

Simply showing me code to add http:// when it does not exist will not help as there are to many case situations that don't apply to just http://

Bruce
  • 1,039
  • 1
  • 9
  • 31
  • That code will already replace `href` that doesn't start with `http://`. Can you be more specific? – FirstOne Aug 04 '16 at 18:47
  • 2
    wouldn't it be better if you just do the reverse and check if it doesn't exist and add to it? http://stackoverflow.com/questions/2762061/how-to-add-http-if-its-not-exists-in-the-url – Funk Forty Niner Aug 04 '16 at 18:48
  • Basically you want to add htttp:// in href when it does not exist? – Rahul Patel Aug 04 '16 at 18:49
  • @FirstOne No it wont that code will only replace href="/ if href="h it will not be replace. nor if href="w nor if href="anything other than href="/ – Bruce Aug 04 '16 at 18:49
  • @Fred-ii- that was precisely the question - how do I do a str_replace when a pattern doesn't exist instead of when a pattern does exist?? – Bruce Aug 04 '16 at 18:53
  • 1
    That link I gave you has quite a few examples Bruce. – Funk Forty Niner Aug 04 '16 at 18:53
  • Unfortunately I don't just want to add http:// where its missing. – Bruce Aug 04 '16 at 19:18

0 Answers0