How can I search and strip a link URL from a comment post and replace it with something like http://www.mydomain.com/redirect.php?c=http://www.poster_domain.com&a=123 Poster's URL link can have a query string (?) or http://www.mydomain.com/redirect.php?c=http://www.poster_domain.com
how does the comment looks like? just "this is some text and my website is astrazone.com" or "this is some other text but my website is still <a href="astrazone.com">astrazone.com</a>"
$pattern = '/(<a[^>]*? href=")([^"]+)/si'; function href_adjuster($matches) { return $matches[1].'http://www.mydomain.com/redirect.php?c='.urlencode($matches[2]); } $text = preg_replace_callback($pattern, 'href_adjuster', $text); PHP: This will urlencode the redirecting href, so you will need to do urldecode($_GET['c']) in redirect.php to get it back to the original
if you still don't have it, i can make you such a php script but for $$$, if you are interested, just PM me how much you are willing to pay.