Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am need to ban this URL to visit my website, but don't know how should I do this?


I'm a new user of Cpanel 11 / Apache / linux Server.

share|improve this question

migrated from stackoverflow.com Apr 1 '12 at 15:54

This question came from our site for professional and enthusiast programmers.

WHat do you mean by ban? Do you want to prevent the above URL from being used? Do you want to prevent your site from being visited from the above URL? – John Percival Hackworth Mar 31 '12 at 16:20

If you mean that you want to prevent people from visiting your site from that url, you can check for the referrer header and redirect people from that address to another page or whatever you want to do with them.

You can do this in your htaccess file with something like this:

RewriteEngine on
RewriteCond %{HTTP_REFERER} ^http://www\.example\.com [NC]
RewriteRule \.png http://www.somewhere.com/something.gif [R]

In PHP you can check for a referrer and redirect them with something like this:

$referer = $_SERVER['HTTP_REFERER'];
if ( $referer != "http://first_url" || "http://second_url" || "http://third_url" || "http://fourth_url" ) {
  header('Location: http://desired_url);
share|improve this answer

I don't know how to block specific URLs but here's how you can block them using their IP address. Place this in an htaccess file in your root web directory:

Order Deny,Allow
Deny from
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.