Add to Favourites Add to Favourites    Print this Article Print this Article

How to restrict IP access to an Apache directory using an .htaccess file?

If you have a path with sensitive data that you don't want to be public, you can restrict the path to only be accessible by your own IP address, using an .htaccess file.

Create the .htaccess file in the path you'd like to protect.
Add this code, where you'd replace with your own IP.

       order deny,allow
       deny from all
       allow from 1.2.3.4
       order deny,allow
       deny from all
Other variations on this are possible, google should have many guides on it.


Was this answer helpful?

Also Read