I need to alter the text in some places which was having missing site url.
Suppose I have a big html code, in that code some places the site url is missing, but some places it has.
Example : /blog/images/image.png
need to alter http://www.domain.com/blog/images/image.png
So I have tried following code,
$html=preg_replace('%/blog/%','http://www.domain.com/blog/',$html);
But with this code it alter the following lines as well,
http://www.domain.com/blog/images/image.png -> http://www.domain.com/http://www.domain.com/blog/images/image.png
How should I skip that ?
Basically I need to add the site url(http://www.domain.com/) to some places only if it is missing.