How To Block (Ban / Restrict) Access To PHP Script Or Page? Yes, You Can Ban Everybody And Allow Only Your Website To Accessing The Page Of Your PHP Script

How To Block (Ban / Restrict) Access To PHP Script Or Page? Yes, You Can Ban Everybody And Allow Only Your Website To Accessing The Page Of Your PHP Script

Did you search for a way, PHP script, just to restricting access of your php page? If that is it my friend, Well, you have come to the right place. Here i'll let you know Just how can you do that with ease using a short line of PHP code. The code is working, and it doesn't require you to know your ip address or some kind, doesn't even require you to learn PHP script, all you need to know is just the address, url of the page that you want to let it able to access the PHP page, and that is it.

Usually, those who need such a code are those who host own PHP script on a limited hosting. The problem doesn't come by the quota or bandwith given, cause generally, at its bad they have approximately 2GB bandwith per month, and that 2GB is not gonna be completely spent out in a month. The problem comes by "bad bots", which the bots are intentially sent by somebody to suck out the bandwith, somebody that might doesn't like those people.

Script Code For Restricting / Banning / Blocking Access To PHP Script Or Page

I've told you, the code is short and so very short. The only thing that you may want to know about the code, about the placement of the code, is that it must be placed on very top line before any other code written. If you put the code after or below the other one, the code may work only on those that are written below it.

The only problem with the code is that you can set only one website to include into the code, if you have two websites to include then you'll need to know about the "if" statement, if you have many websites to include then you'll need to find another way, the code that i'm about to tell here is not intended for such need.

Very well! Here is the code.

<?
$block = getenv('HTTP_REFERER');
if (strpos($block, 'j-smith-site.blogspot.com') != 7) {die("Restricted Area: You got no permittion!"); }
?>

That's it my friend, just replace my blog url with your and well done. There are still many ways that you can find to restrict access of your PHP page, if it's not what you want then just google out. If you take my code but then you face any trouble, then tell me about it and let me help you out.

The following are some posts in relation to PHP script.

http://j-smith-site.blogspot.com/2013/05/create-page-post-views-counter-widget_21.html > Individual Or Single Page Counter / Post Counter Widget For Blogger
http://j-smith-site.blogspot.com/2013/05/page-post-view-counter-hit-stats.html > Daily Page / Post Counter For Blogger
http://j-smith-site.blogspot.com/2013/06/page-counter-post-counter-widget-weekly.html > Weekly Page / Post Counter For Blogger
http://j-smith-site.blogspot.com/2013/06/post-views-widget-based-on-yearly-hits.html > Yearly Page / Post Counter Widget For Blogger
http://j-smith-site.blogspot.com/2013/05/best-free-web-hostings-with-mysql-php.html > Best Free Web Hostings With PHP And MySQL Support

0 comments:

Post a Comment