Prevent sending referrers when clicking links from my site with an exception for one domain
Since the Referrer-Policy: no-referrer
header will instruct the user agent not to send a Referer
header at all, there is little you can do without touching the delivered content. In a usual scenario, the server has no knowledge what kinds of links the content holds, and the options for Referrer-Policy
header only deals with the origin of the request.
The only viable option I come to think is to rewrite content. Since the noreferrer
attribute is widely supported you could use Apache's mod_substitute, for instance.
You would need to formulate a suitable regular expression to match links that you want to include the noreferrer
attribute to. Something like <a\s+[^>]*href="(http://)?www.google.com[^"]*">
will match a
tags pointing to google homepage.