In Ubuntu 11.04, I'm trying to Allow from IP without password prompt, and also allow from any address with password prompt. But it isn't working. Everyone from the Internet can access the page without the password. If I set simple password authentication (without conditions), it works.


  • Some more info: Since .htaccess files are deprecated I edited the /etc/apache2/apache2.conf file – Chetan Crasta Aug 1 '12 at 8:41
  • Post the relevant bits of your Apache config, please. – nickgrim Aug 1 '12 at 9:01
  • <Directory /var/www> Order deny,allow Deny from all AuthName "htaccess password prompt" AuthUserFile /var/www/.htpasswd AuthType Basic Require user xxxxx Allow from 1xx.xx.xx.120 Satisfy Any </Directory> – Chetan Crasta Aug 1 '12 at 9:35
  • Sorry for the missing line breaks. I tried four-space indentation but it didn't work. – Chetan Crasta Aug 1 '12 at 9:42
  • what issues are you facing exactly? You state, ""If I set simple password authentication (without conditions), it works.". If it works -what are you trying to resolve? To do what you are looking for, you have to use htaccess and htpasswd files. – JM4 Aug 13 '12 at 20:39

If you want to block requests completely from other IP's you can do:

<Directory /var/www/sub/payroll/>
Order deny,allow
deny from all
Allow from

It blocks requests from all IP's except the one you specified.

If you want to password promt using .htaccess try this link: http://www.cyberciti.biz/faq/howto-setup-apache-password-protect-directory-with-htaccess-file/

| improve this answer | |
  • No I don't want to block requests from other IPs completely. They should have access after entering a password. I'd rather not use .htaccess files. – Chetan Crasta Aug 1 '12 at 8:43
  • I think you can put it in the apache2 configuration aswell, if you'd rather want that. – Kao Aug 1 '12 at 8:46
  • I tried it using .htaccess — still no luck. – Chetan Crasta Aug 1 '12 at 9:52
  • Are you getting any errors, or is it just not working? – Kao Aug 1 '12 at 10:19
  • It is not working — Internet users are supposed to get a password prompt. Instead they can view the page without entering the username/password. Form the allowed IP address, access is OK. – Chetan Crasta Aug 1 '12 at 10:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.