PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, February 11, 2022

[FIXED] Set up htaccess so that everyone is denied except one IP, BUT it requires authenticaion

 February 11, 2022     .htaccess, apache, lamp, linux, webserver     No comments   

Issue

I want to set up .htaccess on my Apache web server such that all users are straight-up denied access except one user which is my IP. Since this IP represents my entire home network, I also want to add authentication in the case the IP is correct to ensure that only I can access that directory and no one else using my home network.

This is how my .htaccess file looks so far:

Order deny,allow
Deny from all
AuthType Basic
AuthUserFile /var/www/path_to_forbiden_dir/.htpasswd
AuthName "Protected"
require valid-user
Allow from xxx.xx.xx.xxx

where xxx.xx.xx.xxx is my IP

This works in denying IPs outside the local network, however no authentication is shown when I try to access that directory from the IP specified. So, how can I create authentication only for the IP specified?


Solution

Thanks, but I resolved the issue by following the instructions on https://help.ubuntu.com/community/EnablingUseOfApacheHtaccessFiles I had forgotten to set up Directory override of htpasswd in apache2.conf



Answered By - hesson
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing