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

How do Invokable Controllers work in Laravel?

What is the difference between ( for ... in ) and ( for ... of ) in javascript?

How to set up custom error pages in .htaccess for your Apache server (ErrorDocument)

How to find out which php.ini file PHP is using?

How to select all rows for a certain month (or day, year or time), using Eloquent

What is the loop variable in a @foreach loop in Blade?

How to get table column names from a database table in Eloquent?

What are Template literals (Template strings) in JS?

How to sort an array in javascript?

How to hide directory listing in .htaccess?