Return to Snippet

Revision: 12861
at March 30, 2009 22:08 by kossmoss

Initial Code
$host = str_replace('.', '\.', '');
return preg_replace('/href=["|\']?(http:\/\/(?!'.$host.')([^"\']*))["|\']?/ui', "href=\"/go.php?url=$1\" title=\"$1\" target=\"_blank\"", $text);

Initial URL

Initial Description
You can get hostname from script environment - getenv("HTTP_HOST")
(?!'.$host.') matches URLs always except local links

Initial Title
Replace all the links except local - For redirecting

Initial Tags
php, replace, regexp, links

Initial Language