Skip to main content

Ban IP Addresses (not using htaccess)

This script can be used to ban an IP Address from any function on your site.   While a .htaccess file can be used to ban, it cannot be selective by function.   The script will also ban based on partial IP Addresses.   In this example the banned IP Addresses are in a file called IP.dat (in the same directory as the script) with one address per line.

- - Start Script Here - -
$_SERVER['REMOTE_ADDR'];$IP_array file('IP.dat');$IP_array str_replace("\n"""$IP_array);$IP_array str_replace("\r"""$IP_array);
foreach (
$IP_array as $IP_test) {
  if (
substr_count($IP$IP_test) != "0") {
"<script type='text/javascript'>
    alert ('Your IP Address has been banned from the Member's Only Area.');

- - End Script Here - -

Using subdomains with multiSite
If you have a mutliSite account (unlimited domains) at, the default behaviour for subdomains is not intuitive.  If you enter a subdomain that is not specifically defined in the DNS it will default to the primary domain name, even with the wildcard spec in the DNS.  You can fix this using the .htaccess code below in your primary domain.  It will strip off the subdomain and re-route the request back to the proper domain name.  If you do not do this, subdomains will not work properly.

RewriteEngine On
RewriteCond %{HTTP_HOST} !$
RewriteCond %{HTTP_HOST} !^999.999.999.999
RewriteCond %{HTTP_HOST} (www\.)?([^.]+\.)(.*)$
RewriteRule ^(.*)$ http://%3/$1 [L]

Change to your primary domain name and use your IP Address.

Or . . . if you would prefer to just give an error (custom 404) page when an undefined subdomain is entered you can use this htaccess code:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !$
RewriteCond %{HTTP_HOST} !^999.999.999.999
RewriteRule ^(.*)$ 404.php [L]

You can use any custom error page, in this example named 404.php, (you will find one on this Tips site) or make your own.


Popular posts from this blog

All this clearly indicated that Gundred’s interference

All this clearly indicated that Gundred’s interference was urgently needed in the cause of holiness. Day by day she watched the situation, feeling more and more certain that her mission was the rescue of her husband. He, meanwhile, bore hourly, with increasing pain, the tantalizing torments of his paradoxical proximity to the thing he had so long looked for and now had found in vain. Ivor Restormel wondered at his good fortune, and only occasionally noticed the crochets of Kingston and Gundred. Of the two, Gundred had by far the more tactful temperament. Her dislike, now fast verging towards religious horror, was not to be discerned except by an eye far more keen than Ivor Restormel’s. A serene gravity, a cool calm were so much the dominant characteristics of her nature that the exaggeration of her gravity, the additional chill in her calm passed unnoticed by one so little practised in observation. The restless eagerness of Kingston was more plain and more distressing. Ivor Restormel

Dove, fra l'altro, si spiega quale valore desse, il Nostro Cavaliere, alla parola «versipelle»; e di nuove venture che gli toccarono.

Ora il Cavalier Mostardo dormiva nel suo gran letto di quercia massiccia, fra un ritratto di Mazzini ed uno di Garibaldi. Aveva, appeso al muro, sopra il tavolo da notte, dove la gente religiosa tiene l'acquasantiera, una vecchia carabina; la  Santa Carabina ; e, sul tavolo da notte, invece della bottiglia e del bicchiere per l'acqua, era posato un ampio boccale verde con sopravi la dicitura consueta: « Evviva la Repubblica! ». E la Repubblica abitava con lui in quel suo stanzone severo, inelegante, dal mobilio spaiato, dalle pareti squallide; la Repubblica occhieggiava attraverso una grande bandiera rossa, appoggiata in un angolo; sorrideva da un berretto frigio; strepitava in una serie di disegni allegorici incollati al muro; minacciava in una collezione rilegata del vecchio giornale « Aristogitone »; si umanizzava in una statuetta simbolica in coccio, sopra il canterale; si divinizzava nei trionfi dell'ottantanove, matroneggiando in disegni e oleografie sparsi qua e là

The Flame Breathers

I write this narrative, not with the idea of contributing any additional scientific data to the discovery of Vulcan, but to put upon the record the real facts of our truly-amazing space voyage. The newscasters have hailed me as a modern Columbus. Surely I would not want to appear ungracious, unappreciative of all the applause that has been heaped upon me. But I do not deserve it. I did my job for my employers. The Society sent me to make a landing upon Vulcan—if the little planet existed. I found that it does exist; it was exactly where I was told it ought to be. I carried out my instructions, returned and made my report. There is no great heroism in that. So I am writing the facts of what happened. Just a bald, factual account, without the imaginative trimmings. The real hero of the discovery of Vulcan was young Jan Holden. He did his job—did it well—and he did something just a little extra. I'm Bob Grant, which of course you have guessed by now. Peter Torrence—the third m