0

i want an exclusive access in my administration folder and i tried this code (in an .htaccess file inside admin folder):

order allow,deny
allow from m.y.i.p
deny from all

tried also this:

order deny,allow
deny from all
allow from m.y.i.p

and this:

order deny,allow
allow from m.y.i.p
deny from all

but anytime server gives me this response:

403 Forbidden

Forbidden You don't have permission to access /provo/prova/ on this server.

how can i solve this issue? i have a switch connected to the router/modem and i take my ip address from this site http://whatismyipaddress.com/

thanks.

Oussama Jilal
  • 7,669
  • 2
  • 30
  • 53
Switi
  • 1
  • 1
  • 1
  • Possible duplicate of [Deny all, allow only one IP through htaccess](http://stackoverflow.com/questions/4400154/deny-all-allow-only-one-ip-through-htaccess) – IvanRF Sep 02 '16 at 23:28

3 Answers3

1

This worked for me:

Order deny,allow
deny from all
allow from m.y.i.p

However, since you've already tried it, you need to make sure that's the IP the webserver is seeing. Look at the access logs right after you load a page to see what IP got logged.

Other than that, make sure that you've put these in the right place. Either the htaccess file in the directory you want to protect, or in a <Directory> block in your server/vhost config.

Jon Lin
  • 142,182
  • 29
  • 220
  • 220
0

Prob not the answer you're looking for but:

If you're using cPanel .. it's really easy to do it from there.

It involves making a passwords file. I never remember the exact way cause I always get cPanel to do it for me.

I would only do it by IP if you have been given a static IP from your ISP... otherwise this could change.

David Sigley
  • 1,126
  • 2
  • 13
  • 28
0

Use .htpasswd. It's a bit more resilient than just using an IP address.

James
  • 13,092
  • 1
  • 17
  • 19
  • It's also possible to spoof an IP address. Against a determined attacker nearly any form of online security can be defeated. If you're that worried, don't store your data online. – James Aug 28 '12 at 12:49
  • no dubt. and if i want to block the access to a specific subfolder from .htaccess on the root, what is the way? – Switi Aug 28 '12 at 15:51