WHAT YOU NEED TO KNOW ABOUT ADBLOCK SOFTWARE
Are you blocking our ads? Or would you rather not view them? Click here to go ad free on this site

How to Mask your URLs from Adblocking software

Masking Links
A technique to avoid the effect of adblock software is to mask the information that the software is looking for. Any URL is susceptible to blocking by adblock software, whether it is is an image url, Javascript, or a click URL.

A simple technique is to use a server side programming language to handle every url through your own server with a redirect.


For example, let’s
say you have the following click url:

http://www.blockeddomain.com/click-1234567890.

When adblocking software sees that URL, it strips it from the HTML before it reaches your viewer. The task is to prevent the adblock software from seeing that URL by hiding it behind a redirect script on your site.

There are a number of techniques to do this, but basically you need to call a script on your site and tell it the real URL that it should redirect to. If you have all your links in a database, your redirect URL can look something like this:

http://yoursite.com/redirect.php?id=123

When the redirect script runs, it looks up link #123 in the database and redirects the user to the URL with that ID.

If you don’t have a database, however, or have lots of URLs to mask, there is an easier technique. If you simply pass the URL to the redirect script, you don’t have to worry about any database programming:

http://yoursite.com/redirect.php?url=http://www.blockeddomain.com/click-1234567890

In that case, your redirect script gets the URL passed to it and simply redirects to the url it got in the query string. There’s a problem with that, however. The url is still visible. So, we need to scramble it a bit which we will do by reversing it:

http://yoursite.com/redirect.php?url=0987654321-kcilc/moc.niamoddekcolb.www//:ptth

Now, when your script gets the url passed in, it simply reverses it before doing the the redirect. And, there’s nothing there for the adblock software to recognize and block.

The Code
The redirect.php script looks like this:

<?php
$url = strrev($_GET["url"]);
header("Location: $url");
?>

The strrev PHP command reverses the string in the url parameter. The header command issues the redirect. Now all you need to do is call this script with the real url in the url parameter, reversed, like this:

http://yourdomain.com/redirect.php?url=0987654321-kcilc/moc.niamoddekcolb.www//:ptth

Now the trick is to do this with all the URLs on your site that may get blocked. Again, you can use PHP to do the work for you in reversing the URLs. Each time you print a URL that you want to protect, use the following code:

<a href="redirect.php?url=<?php echo urlencode(
     strrev(
     "http://www.blockeddmomain.com/click-1234567890")); ?>">Click Me

The strrev command reverses the URL. the urlencode command encodes any special characters that may interfere with the redirect.php querystring.

It’s as simple as that. A little extra programming can save you and your visitors from the frustration of having legitmate HTML blocked by adblocking software.

10 Responses to “How to Mask your URLs from Adblocking software”

  1. Anonymous Says:

    Thanks for the hint. I just added *//:ptth to my adblocker.

  2. AdBlock Says:

    Touche. That’s prerogative and I have no problem with your doing so. If I did, I’d simply detect that you’re blocking certain content and block your access entirely, some may feel that strongly and while it’s your choice to block the ads, it should be a website owner’s choice to deny your viewing the remainder of the content.

    The important difference is that you’re actively filtering your own content, as you should.

    It’s the fact that there are people who don’t know what’s getting blocked that is concerning.

  3. Altjira Says:

    I hereby claim authorship of the first comment and do no apologize for it.

    Kudos to AdBlock. I checked back in to see whether my rather flippant comment, or even the entire discussion, had been deleted, and was pleasantly surprised to see that it was not.

    Based on your response, and further perusal of the website, I see that this is a “fair and balanced” discussion of the topic of adblockers (no irony intended). I acknowledge the balanced view you bring to the topic, and the importance of the discussion of the subject to the future the entire internet.

    While I have a negative knee-jerk reaction to the intrusion of advertising-supported content on a medium that I have been using for over twenty years, I see your point in describing the positive aspects. I will admit both to channel-surfing during the ads on commercial tv and inconsistent support of one of my other favorite media, public radio and tv. It seems that I cannot without difficulty overcome my desire to get what I want for free.

    As regards to the topic above, it gives real insight to webmasters who rely on commercial support for their efforts and are responsible to their supporters. My counterpoint to your solution merely demonstrates that the principle you are advocating is effective. There is no way I can program my adblocker (the Adblock extension for Mozilla) to counter all the permutations if the general solution you advise, and any competant programmer realizes it.

    Hopefully, commercial advetisers will realize that the ability to avoid their so-called “targeted advertising” is advancing as quickly as the advetiser’s ability to target it, and will give due deference to those responsible webmasters that can demonstrate their ability to deliver the desired message to the intended recipients. I generally resist the advertiser’s efforts, but ultimately, I would rather surrender personal information to the New York Times website (for example) in order to access their content than to pay a monthly fee.

    As realist, I will accept advertising to pay for my content. As a technologist, I will resist doing so with all the tools at my disposal. To reach people like me, advertisers will have to expend a significantly greater amount of effort. My ability to escape advertising relies on the stupidity (PC: lack of sophistication) of the average internet user.

  4. AdBlock Says:

    Altjira, thanks for coming back, owning up, and commenting further. I also appreciate (as a fellow 20+ year user of the medium) your perspective.

    I believe that above all, discussion and awareness to this issue is critical.

  5. Steve Jeffrey Says:

    Thank you for this great script. I am having trouble implementing the concept because the page that calls the redirect.php script is HTML, not PHP. Is there a way that I can perferm the equivalent strrev function from an HTML page?

  6. Khalid Boussouara Says:

    —–BEGIN PGP SIGNED MESSAGE—–
    Hash: SHA1

    I am also adding this to my adblock config. There are hundreds of ads
    which I am ok with. However I do not like websites which try to hide
    URL’s. To me this is the same as a website which changes the status bar
    (I’ve disabled that in firefox) to prevent me from checking the URL. I
    want to know where a URL leads to before I click on it.

    If you are wondering why this message is GPG signed then I’m just trying out using it. Also because this site has no login so it’s easier for trolls to impersonate people.
    —–BEGIN PGP SIGNATURE—–
    Version: GnuPG v1.2.1 (MingW32) - WinPT 0.7.96rc1

    iD8DBQFCMEMNkKe5/Gvxc3gRAu8PAKCCfd9zAWo36yo67+QYwt4aDjJ4EQCfWQdg
    D2aqs8rgzVvFlWy3kgDiuv4=
    =JwbG
    —–END PGP SIGNATURE—–

  7. BEGIN PGP SIGNATUR Says:

    as we care :p !

  8. Anonymous Says:

    lick lick lick

  9. blockads Says:

    Lets all join forces to block such adlock discovery utilities first !

    =========================================
    = Say NO to web ads ! Reclaim your web! =
    = You have the right to block ads ! =
    =============blockads@gmail.com=============

    Post comments to :
    blockads@gmail.com

    Use firefox http://www.mozilla.org/support/firefox/adblock

  10. Rudolf Polzer Says:

    —–BEGIN PGP SIGNED MESSAGE—–
    Hash: SHA1

    Yes, and there’s another problem - doing this will some time result
    in Adblock following and checking redirects. In the end, this will
    not help.

    Plus, nobody complains about simple banner ads. The thing Adblock was
    invented for are intrusive popup or layer ads. I think there should be
    an option for Firefox Adblock to block ads only for