How to block access to certain referrers in Apache using .htaccess

Apache: How to block access to certain referrers in Apache using .htaccess

Here are the rules you need if you want to block access to any request that contains a certain referring URL

  1. RewriteCond %{HTTP_REFERER} bad-site-linking-to-your\.com [NC,OR]
  2. RewriteCond %{HTTP_REFERER} another-bad-site-linking-to-you\.com [NC]
  3. RewriteRule .* - [F]

webdevetc profile pic
webdevetc

I am a 29 year old backend web developer from London, mostly focusing on PHP and Laravel lately. This (webdevetc.com) is my blog where I write about some web development topics (PHP, Laravel, Javascript, and some server stuff). contact me here.



More...


Comments and discussion about How to block access to certain referrers in Apache using .htaccess

Found this interesting? Maybe you want to read some more in this series?

Or see other topics in the Apache language

Or see other languages/frameworks:
PHP Laravel Composer Apache CentOS and Linux Stuff WordPress General Webdev and Programming Stuff JavaScript
Or see random questions

How to run an artisan command from a controller

Why should you update APP_URL from from http://localhost?

How to return an item in Eloquent, or throw a ModelNotFoundException exception if it isn't found?

What is the loop variable in a @foreach loop in Blade?

What is the difference between empty(), isset(), != null, is_null() in PHP

How to select what columns to return when calling ::all()

How to add comments in PHP

How to set up an alias to map one directory to another destination

How to hide the server signature (hide Apache info) from HTTP headers with .htaccess

How to order a Laravel hasMany relationship?