Currently I detect links in text submitted by users and rewrite them like this:
$setUrl = preg_replace("/(http:\/\/|(www\.))(([^\s<]{4,68})[^\s<]*)/", '<a href="/link/$2$3" rel="nofollow">$2$4</a>', $extUrlStr);
But I need to be able to detect if the link is pointing to a page on my own domain or not and based on that I'll take different actions. If on my own site, skip the rewrite above if outside -- rewrite.
Sort of lost.