Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New to the CF scene
    Join Date
    Mar 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    .htaccess question

    Is there a way to only deny IPs from a certain file, isntead of a directory?
    Thanks.

  • #2
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I believe this will work:

    Code:
    <Files file.txt>
    Order Allow,Deny
    Deny From IP-ADDR
    </Files>
    If not then I will have to look it up again , 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.

  • #3
    New to the CF scene
    Join Date
    Mar 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sorry, you lost me there...where do I put that? It looks like html to me, not .htaccess code.. :| sorry, idiot here

  • #4
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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:

    Code:
    <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:

    Code:
    <Files bar.html>
    to

    Code:
    <Files *.html>
    Then whenever someone tried to access a file with a .html extension, they would get a permission denied message.

  • #5
    New to the CF scene
    Join Date
    Mar 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    How about only allowing my own IP in?

  • #6
    Regular Coder Feyd's Avatar
    Join Date
    May 2002
    Location
    Los Angeles, CA Maxim: Subvert Society
    Posts
    403
    Thanks
    0
    Thanked 0 Times in 0 Posts
    <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]
    Moderator, Perl/CGI Forum
    shadowstorm.net - subvert society

  • #7
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hey Feyd, it was your tutorial on Javascriptkit that I read, and that thats where I learnt most of the htaccess stuff i know

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

  • #8
    Regular Coder Feyd's Avatar
    Join Date
    May 2002
    Location
    Los Angeles, CA Maxim: Subvert Society
    Posts
    403
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    Moderator, Perl/CGI Forum
    shadowstorm.net - subvert society


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •