/ Published in: PHP
![](/img/icon_sav.png?v3)
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
![RSS Feed for Comments RSS Icon](/images/rss.png?v3)