/ Published in: PHP

You can get hostname from script environment - getenv("HTTP_HOST")
(?!'.$host.') matches URLs always except local links
(?!'.$host.') matches URLs always except local links
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
return preg_replace('/href=["|\']?(http:\/\/(?!'.$host.')([^"\']*))["|\']?/ui', "href=\"/go.php?url=$1\" title=\"$1\" target=\"_blank\"", $text);
Comments
