Blocking referrers with Apache

A referrer tells the webserver the location of the last page viewed by your browser. It is normally sent from the browser to the Apache webserver every time the browser requests information.

This information could be used to control access to your site, for example to avoid others link your site’s images.

Add the following to your Apache configuration file:

RewriteEngine On
RewriteCond %{HTTP_REFERER} ^.+.blockthis.com/.*$ [NC]
RewriteRule ^/(.*) http://www.google.com/ [R,L]

If you don’t understand the above, please take a look a the Apache mod_rewrite manual page. You could also try this very interesting mod_rewrite manual.

One Response to “Blocking referrers with Apache”

  1. anonymous says:

    Why not just deny the bad guy out of site?

    order allow,deny
    allow from all
    deny from 123.45.67.89

Leave a Reply

You must be logged in to post a comment.