Anonymize outbound links on your site using anon.to's direct redirect.
Prefix any URL with
https://anon.to/?
and visitors will be redirected anonymously — no referrer, no tracking. Nothing is stored or logged.
Add this script to your page to automatically rewrite all external links.
<script>
document.addEventListener('DOMContentLoaded', function () {
var host = location.hostname;
document.querySelectorAll('a[href^="http"]').forEach(function (a) {
try {
if (new URL(a.href).hostname !== host) {
a.href = 'https://anon.to/?' + a.href;
}
} catch (e) {}
});
});
</script>
Use this function to rewrite external links in HTML content server-side.
function anonymizeLinks(string $html, string $domain): string
{
return preg_replace_callback(
'/<a\s([^>]*?)href=["\']?(https?:\/\/[^"\'\s>]+)["\']?/i',
function ($m) use ($domain) {
$host = parse_url($m[2], PHP_URL_HOST);
if ($host && !str_ends_with($host, $domain)) {
return '<a ' . $m[1] . 'href="https://anon.to/?' . $m[2] . '"';
}
return $m[0];
},
$html
);
}
// Usage:
echo anonymizeLinks($html, 'yourdomain.com');