...

View Full Version : .htaccess question



c0Ld
03-14-2004, 09:20 PM
Is there a way to only deny IPs from a certain file, isntead of a directory?
Thanks.

missing-score
03-14-2004, 09:43 PM
I believe this will work:


<Files file.txt>
Order Allow,Deny
Deny From IP-ADDR
</Files>

If not then I will have to look it up again :p, aint done this for a while. you can also use wildcards (*), so you could deny access to all files in a directory without actually denying access to the directory.

c0Ld
03-15-2004, 03:13 AM
Sorry, you lost me there...where do I put that? It looks like html to me, not .htaccess code.. :| sorry, idiot here

missing-score
03-15-2004, 12:07 PM
That is Htaccess code, trust me on this one :)

You put that in your .htaccess file like you normally would. Are you familiar with using a .htaccess file? Heres an example:

Say you have directory foo, which contains files index.html and bar.html. You want to stop anyone accessing bar.html.

In directory foo you place a file called .htaccess with this information:


<Files bar.html>
Order Allow,Deny
Deny From All
</Files>

Then when people access foo/bar.html, they will get an error saying that access is denied.

Say you then decided that you wanted to restrict all access to .html documents, you could change this line:


<Files bar.html>

to


<Files *.html>

Then whenever someone tried to access a file with a .html extension, they would get a permission denied message.

c0Ld
03-15-2004, 10:16 PM
How about only allowing my own IP in?

Feyd
03-15-2004, 10:27 PM
<Limit GET POST>
order deny,allow
deny from all
allow from 127.0.0.1
</Limit>

Remember that everyone not on your IP will get a 403 error...so if you are turning your site off to debug or something, consider mod_rewrite.

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REMOTE_HOST} !^your\.ip\.add\.ress
RewriteCond %{REQUEST_URI} !/notification_page\.html$
RewriteRule \.html$ /notification_page.html [R=302,L]

missing-score
03-15-2004, 10:52 PM
Hey Feyd, it was your tutorial on Javascriptkit that I read, and that thats where I learnt most of the htaccess stuff i know :D

Just a question about the above, the <Limit GET POST>, what does that do?

Feyd
03-16-2004, 05:26 PM
LIMIT [args]: the args are the HTTP method you want the control (denying) to be limited to...in your case, GETting pages and POSTing to pages.

The available arguments are GET, POST, PUT, DELETE, CONNECT, OPTIONS, TRACE, PATCH, PROPFIND, PROPPATCH, MKCOL, COPY, MOVE, LOCK, and UNLOCK. They are case-sensitive. When using GET, it also by default restricts HEAD requests.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum