Advanced .htaccess Security – Block Unwanted Referrers
For some bloggers and web developers, Digg can be a huge boost in traffic and thus a huge bust in ad revenue. Unfortunately, the Digg Effect can kill a website's bandwidth and get the website shut down. Wouldn't it be great if a weary web developer could prevent his site from being shut down by blocking users referred by Digg, at least a while? Using a small bit of .htaccess code and mod_rewrite, the developer can do just that.
The Code
RewriteEngine on
RewriteCond %{HTTP_REFERER} digg.com [NC]
RewriteRule .* - [F]
Say good-bye to Digg Death with this small, easy-to-place snippet of code!
For maximum performance, we all know we must put our assets on CDN (another domain). Along with those assets are custom web fonts. Unfortunately custom web fonts via CDN (or any cross-domain font request) don't work in Firefox or Internet Explorer (correctly so, by spec) though...
This is the hardest thing I've ever had to write, much less admit to myself. I've written resignation letters from jobs I've loved, I've ended relationships, I've failed at a host of tasks, and let myself down in my life. All of those feelings were very...
"Enabling" you ask? Yes. We all know how to disable the submit upon form submission and the reasons for doing so, but what about re-enabling the submit button after an allotted amount of time. After all, what if the user presses the "stop"...
Last year I wrote a popular post titled AJAX For Evil: Spyjax when I described a technique called "Spyjax":
Spyjax, as I know it, is taking information from the user's computer for your own use — specifically their browsing habits. By using CSS and JavaScript, I...
David,
I have a quick question for ya… can you make this .htaccess so you can transfer them to a “slimmed” down version of the same page or simply a blank page that says sorry digg users the site is offline for awhile?
One more question. When digg or any other site goes down for scheduled maintenance do they use this method to redirect all pages to a sorry we are down page?
Mark
Not a bad idea with your first question, Mark. Per your idea, I’d create a new sort of page template to do this. Say that “page.php” is getting hit hard and you want to show a slimmed down page. On page.php, you could check the referrer and if the referrer was digg, you could do a header() redirect to “slimpage.php?page=”.(yourpage). You’d them have slimpage.php provide a text-only version of your article.
As for a site being down, I’d bet that this is what they do. It’s very easy and very simple. Unfortunately, Digg, for example, doesn’t allow you to view their .htaccess file anymore.
What do you think abut blocking : “Options FollowSymLinks”, i think this is important also