Hi everyone,
I've been trying to figure this out for two days. I've exhaustively searched the web and this forum and can't seem to figure out what I'm doing wrong.
I want to prepend all links from a particular domain (foo.com) with a link to my script, such that the link becomes a GET argument to my script. I only want this to do for that particular domain, and leave other domains alone. Here's what I have so far:
$search='@<a([^>]+?)href="(.+?)foo.com\/(.+?)"(.*?)>(.+?)<\/a>@si';
$replace='<a$1href="myscript.php?fp=$2foo.com/$3"$4>$5</a>';
$out=preg_replace($search,$replace,$page_to_parse);
Strangely enough, this does the replacement for all links except those originating from foo.com! Any help is greatly appreciated.
EDIT: I escaped the /'s after foo.com and in the </a> in my post, but the board stripped them out.
Thanks, Matt