How to have a whitelist of IP addresses that can access files in .htaccess

Apache: How to have a whitelist of IP addresses that can access files in .htaccess

If you want Apache to only allow access to files/directories that match a set of IP addresses you can use this:

  1. <Files admin_panel.php>
  2. Order deny,allow
  3. Deny from all
  4. Allow from x.x.x.x localhost
  5. </Files>

Remember to change admin_panel.php and X.X.X.X to your details

webdevetc profile pic
webdevetc

I am a 29 year old backend web developer from London, mostly focusing on PHP and Laravel lately. This (webdevetc.com) is my blog where I write about some web development topics (PHP, Laravel, Javascript, and some server stuff). contact me here.



More...


Comments and discussion about How to have a whitelist of IP addresses that can access files in .htaccess

Found this interesting? Maybe you want to read some more in this series?

Or see other topics in the Apache language

Or see other languages/frameworks:
PHP Laravel Composer Apache CentOS and Linux Stuff WordPress General Webdev and Programming Stuff JavaScript
Or see random questions

What is the difference between integration and unit tests?

How to Extract Query String (from a URL) Into an Associative Array in PHP

How to force SSL in Apache's .htaccess?

How to add the CSRF (Cross-site request forgery) token in Laravel?

How to disable file hotlinking in Apache with .htaccess

How to block an IP address in .htaccess

What is WordPress default Apache .htaccess rules?

How to set the Expires header in .htaccess

How to add the default charset to UTF-8 in .htaccess

How to output (echo/print) content in PHP