tags:

views:

47

answers:

3

i want to protect some folders from a normal user but i (from localhost or my IP address) m unable to see the folder structure...so i do this

write a .htaccess file in that folder(eg.project/cms/js) and write below code

# no nasty crackers in here!
order deny,allow
deny from all
allow from 192.168.1.7

but by using this prohibit to everyone( including me) to see that folder structure..... how do i protect that folder from other users except myself?

A: 

This article outlines it quite well: Comprehensive guide to .htaccess password protection

Pekka
that is for linux....can u solve throug my htaccess file i have written above please
diEcho
It's for Apache and works on Windows as well. You just need to replace paths. However, it presents a password check, it's not an IP filter (what is what you seem to be looking for.)
Pekka
+1  A: 

I think you got the allow and deny the wrong way around:

order allow,deny
allow from 192.168.1.7
deny from all

which first processes all the allow statements and next the deny statements.

Coroos
it does not work dude....still i can't enter that folder`Access forbidden!` is coming
diEcho
*Is* your IP 192.168.1.7?
Pekka
@Pekka yes sir. but i used 127.0.0.1 also
diEcho
@I like PHP check my 2nd answer.
Pekka
+1  A: 

I just checked, your above example works fine for me on my Apache 2. Make sure your IP really is 192.168.1.7. Note that if it's the local machine you're trying to access, your IP will be 127.0.0.1.

Pekka
i also use 127.0.0.1 but still `Access forbidden!` is coming on that folderactually i hev aritten htaccess inside that folder, is that wrong??
diEcho
No, that's all right. Strange, works for me!
Pekka
i put .htaccess on `C:\xampp\htdocs\project\cms\includes`and not working ...also i have restart xampp...
diEcho
@I Like no need to restart XAMPP for htaccess files. You would have to check what client IP you have, something might be wrong there. You can find out using `phpinfo()`
Pekka
`_SERVER["SERVER_ADDR"]=127.0.0.1` and`_SERVER["REMOTE_ADDR"] =127.0.0.1` is shown in phpinfo()
diEcho
And you if use your above example and use `allow from 127.0.0.1` you're 100% sure it doesn't work?
Pekka
yes sir... i m doing so... always say `Access forbidden!`
diEcho
@I like PHP and you are totally sure there is no other `.htaccess` file in one of the parent directories? Or a `deny from all` directive somewhere in the Apache config?
Pekka
i cant't say sure about this..let me check.
diEcho