Switi
Switi

Reputation: 1

.htaccess: how to deny access to all except by me for specific folder

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.

Upvotes: 0

Views: 3320

Answers (3)

Jon Lin
Jon Lin

Reputation: 143966

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.

Upvotes: 1

James
James

Reputation: 13511

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

Upvotes: 0

David Sigley
David Sigley

Reputation: 1198

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.

Upvotes: 0

Related Questions