Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a site where I have various advertisements from a few advertiser , and from time to time my site is redirected how many other porn sites etc ... I installed anti adblock script because I gain from ads! On my site are not installed link or script redirect or for pop-up . 


What I have tried:

Is there any way I can block these redirect injections that come from ads from php, java or htaccess? thanks
Posted
Updated 11-May-20 4:30am

1 solution

Depending on the types of advert you're showing and how they're embedded, you might be able to do something with a content security policy (CSP):
Content-Security-Policy - HTTP | MDN[^]
CSP Cheat Sheet[^]

This would let you lock down your site to only load scripts / images / frames / etc. from a specified list of domains. If an advert tried to load a script from a domain that wasn't in the list, all modern browsers would block it.

But if you can't trust the company that's serving up your adverts, then you shouldn't use them.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900