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 split a string into an array, in JS

What is an example of an object literal?

How to have a whitelist of IP addresses that can access files in .htaccess

How to get the type of a variable in JS?

How to output (echo/print) content in PHP

How to make multiple routes share the same URL structure or URL parameters

What is camel case?

How to convert a string to an array of it's characters in PHP?

How to use Anonymous classes in PHP 7?

What are some ways you can log debug messages and data in JS?