View Full Version : .htaccess question

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

03-14-2004, 10:43 PM
I believe this will work:

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

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.

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

03-15-2004, 01: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

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>


<Files *.html>

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

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

03-15-2004, 11:27 PM
<Limit GET POST>
order deny,allow
deny from all
allow from

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]

03-15-2004, 11: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?

03-16-2004, 06: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.