How to allow access to a single IP address using .htaccess

In the following example, we will assume that you want to allow access only to 1.2.3.4 IP address. The code that you will need to add in your .htaccess file is:

# Order Allow, Deny

Deny from All
Allow from 1.2.3.4

Order keyword here specifies the order in which allow, deny access would be processed. For the above ‘Order’ statement, the Allow statements would be processed first and then the deny statements would be processed.

Was this article helpful?

Thanks for your opinion!
Have more questions? Submit a request