Secure directory by allowing access to IP address & Deny all using htaccess
November 3, 2016 Comments 0 83 Views

Secure directory by allowing access to IP address & Deny all using htaccess

Your website may have folders which you want to keep secure access using URL. For example Admin area you want to keep secure to access using particular IP address and deny and restrict all other access.

Restrict all other with secure directory & Allow access to IP.

By adding few line of code in your htaccess file you can deny / restrict access to certain folders. Also you can allow only few IP address which can only access that directories. This will secure directory which are important and contain confidential data.

Deny all user to access directory.

Add below code in your htaccess file to deny access to all users for directory. For this you need to add htaccess in the directory which you want to deny access.

Deny from all but allow from certain IP address

Add below code to deny all user from accessing directory but still allow some IP address to access this directory. This comes handy to secure your admin directories. Below code should be added in htaccess and htaccess file needs to be in that particular folder which you want to secure access for.

Allow all but deny access to certain IP address.

There are certain condition where you want to keep your directory open but want to restric certain IP address. This comes in use when you want to block spammings which is accessing your directory from certain IP address. Below code should be added in htaccess and htaccess file needs to be in that particular folder which you want to secure access for.

Above tricks of htaccess directory restriction will also affect search engine crawler. So please add the IP restrictions carefully to your website directories.

Previous How to detect website is access from Mobile using PHP.
Next Change admin username in wordpress for security

About author

Rio
Rio 34 posts

Expert web developer working in PHP, Wordpress, Joomla, Magento, Javascript etc.

You might also like

Post data to third party site using PHP CURL

PHP supports CURL library which allows you to connect and communicate to many different types of servers with many different types of protocols and supports the http, https, ftp etc.

Working with PHP Array – Indexed, Associative & Multi-Dimensional

PHP Array are variables which can hold more than one value at a time. For example if you want to store 1000 numbers then instead of defining 1000 variables its easy

Difference between echo and print statements

In PHP there are two basic ways to get your output : echo and print statements. We will show the difference between echo and print statements with a working example.

PHP 7 Using New Operators

PHP 7 also brings us some new operators. Let’s just cut the talk and directly check how PHP 7 Using New Operators. Spaceship Operator : The spaceship operator, or Combined Comparison

PHP function to sort array alphabetically or numerically in ascending or descending order.

In this article we will walk through with example on how the PHP array sort functions works to sort the arrays key and values in alphabetically/numerically or ascending/descending order. Sort

ZIP Files & Folder using Simple PHP Code

Using PHP you can Zip Files and Folders with a simple php code, which will provide you with the functionality to create zip automatically without manual efforts. Simple PHP code to

Working With PHP & Databases

Working with PHP & Database require basic knowledge of below items : Database Connection Inserting Data Reading Data Updating Data Deleting Data Making Database Connection : Using PHP you can

How to detect website is access from Mobile using PHP.

Todays trend shows that maximum number of website access using mobile is increased. People are using smart phone to access the mobile instead of their desktop OR laptop. Because mobile

Error Handling in PHP 7

The next feature we going to cover are the changes to Error Handling. Handling fatal errors in the past has been next to impossible in PHP. A fatal error would

0 Comments

No Comments Yet!

You can be first to comment this post!

Leave a Reply

18 − 4 =