Anonymous link generator
Anonymous link redirection. Referrer hidden, zero tracking.
How it works
- Confidentiality
-
It prevents the destination website from knowing which page referred you to it. The referrer is stripped by both an HTTP header and a meta tag, then you're redirected instantly, even with JavaScript disabled.
- Anonymity
-
It limits third-party advertising and analytical tracking. Analytics scripts on the destination site can't learn which page referred you there, reducing cross-site profiling by ad networks.
- Privacy protection
-
No database, no cookies, no third-party scripts are involved, and redirect pages are never cached or indexed by search engines. Only your outbound link matters, nothing else is stored.
Integrate
Route every external link on your site through Nullrefer automatically. Internal links are left untouched.
Paste before </body>. Runs in the browser.
<script>
function nullreferLinks(domain = location.hostname) {
const PREFIX = 'https://nullref.li/?';
const NULLREFER_HOST = 'nullref.li';
const SELECTOR = 'a[href]:not([data-nullref]):not([data-no-nullref])';
// lowercase, no trailing dot, no "www."
const normalize = host => host.toLowerCase().replace(/\.$/, '').replace(/^www\./, '');
const base = normalize(domain);
function processLink(a) {
const raw = (a.getAttribute('href') || '').trim();
// Only keep http://, https:// and // (skips relative links, mailto:, tel:, #, javascript:...)
if (!/^(?:https?:)?\/\//i.test(raw)) return;
let url;
try {
url = new URL(raw, location.href);
} catch (e) {
return; // Invalid URL: leave the link untouched
}
const host = normalize(url.hostname);
const isInternal = host === base || host.endsWith('.' + base);
if (isInternal || host === NULLREFER_HOST) return;
// setAttribute also works for SVG <a> elements, unlike a.href = ...
a.setAttribute('href', PREFIX + url.href);
a.dataset.nullref = '1';
a.dataset.nullrefOriginal = url.href; // original link kept, handy for debugging
}
function processTree(node) {
if (node.nodeType !== 1) return;
if (node.matches(SELECTOR)) processLink(node);
node.querySelectorAll(SELECTOR).forEach(processLink);
}
function start() {
processTree(document.documentElement);
// Content injected dynamically after the page has loaded
new MutationObserver(mutations => {
mutations.forEach(m => m.addedNodes.forEach(processTree));
}).observe(document.documentElement, { childList: true, subtree: true });
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', start, { once: true });
} else {
start();
}
}
// Usage
nullreferLinks('yourdomain.com');
</script>
function nullreferLinks(string $html, string $domain): string
{
$prefix = 'https://nullref.li/?';
// Accepts both "yourdomain.com" and "https://www.yourdomain.com/"
$domain = parse_url($domain, PHP_URL_HOST) ?: $domain;
$normalize = static fn (string $host): string =>
(string) preg_replace('/^www\./', '', rtrim(strtolower(trim($host)), '.'));
$belongsTo = static fn (string $host, string $base): bool =>
$host === $base || substr($host, -(strlen($base) + 1)) === '.' . $base;
$domain = $normalize($domain);
// 1) Isolate each <a ...> tag, 2) only modify its href attribute.
return (string) preg_replace_callback(
'/<a\b[^>]*>/i',
static function (array $tag) use ($prefix, $domain, $normalize, $belongsTo): string {
if (stripos($tag[0], 'data-no-nullref') !== false) {
return $tag[0];
}
return (string) preg_replace_callback(
// (?<![\w:-]) prevents matching "data-href=", "xlink:href=", etc.
'/(?<![\w:-])(href\s*=\s*)(?:"([^"]*)"|\'([^\']*)\'|([^\s"\'>]+))/i',
static function (array $m) use ($prefix, $domain, $normalize, $belongsTo): string {
$url = trim($m[2] ?? $m[3] ?? $m[4] ?? '');
// Only http://, https:// and // (skips relative links, mailto:, tel:, #, javascript:...)
if (!preg_match('~^(?:https?:)?//~i', $url)) {
return $m[0];
}
$host = parse_url($url, PHP_URL_HOST);
if (!is_string($host) || $host === '') {
return $m[0]; // Invalid URL: leave untouched
}
$host = $normalize($host);
if ($belongsTo($host, $domain) || $host === 'nullref.li') {
return $m[0];
}
if (strncmp($url, '//', 2) === 0) {
$url = 'https:' . $url;
}
$quote = $m[3] !== null ? "'" : '"';
return $m[1] . $quote . $prefix . $url . $quote;
},
$tag[0],
1, // only one href per tag
$count,
PREG_UNMATCHED_AS_NULL
);
},
$html
);
}
// Simple usage
// echo nullreferLinks($html, 'yourdomain.com');
// Automatic usage for the whole page (place at the very top, before any output)
// ob_start(fn (string $html) => nullreferLinks($html, 'yourdomain.com'));
DMCA
If a generated link points to content that infringes your copyright, send a notice to contact@nullrefer.net. Your request will be processed within 48 hours.
Please include the concerned page URLs and explain the reason for the removal request.