Results 1 to 5 of 5

Thread: .htaccess file question

  1. #1
    Join Date
    Nov 2008
    Location
    The Sunshine State
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question .htaccess file question

    Hi!

    I have a couple of questions regarding .htaccess files. I have a .htaccess file running on my site (in the root directory) that has a list of banned IP Addresses to block from viewing the site. Aside from using it for that purpose, I also want to use it to disable hot linking and a couple of other things but I cannot have more than one .htaccess file in the same directory?

    I was going to generate a code on Dynamic Drive to disable hot linking on my site so can I just add the code to my existing .htaccess file (the one with banned IPs)?

    Last question is....how can I use a .htaccess file to block ALL access to a specific directory? I don't mean to make it password protected...I mean to where if anyone tries to visit that directory or any pages in it, they will get a 403 Forbidden page?

    Thanks in advance!!

    -Allen

  2. #2
    Join Date
    Apr 2006
    Posts
    190
    Thanks
    3
    Thanked 7 Times in 7 Posts

    Default

    Ryan
    Sevierville, TN

  3. #3
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    .htaccess is proprietary and controls everything in the directory it is in plus everything in a directory lower than it. No you can't have 2 in the same spot. One would over write the other when you saved cause they have the same name.

    Yes you just add the code to the current .htaccess.

    for blocking the directory...

    Code:
    <directory "path/to/directory">
    order deny,allow
    deny from all
    </directory>
    For others see B&T's
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  4. #4
    Join Date
    Nov 2008
    Location
    The Sunshine State
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Ok as far as using more than one in the same directory, what if I put 2 in there with one having a different name by using the "AccessFileName .filename" feature...would that work?
    The reason I want more than one in the same directory (the main directory of my site) is to perform more than one function that .htaccess files can do.

    For example, I need one to block the banned IPs and I need another one for custom error messages.

    Allen

  5. #5
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    All in the same .htaccess... the file itself will do what is inside it, throw a password prompt, block an IP, redirect, change http://yoursite.com to http://www.yoursite.com... parse html pages as php and on and on and on... just put the code in the file upload and you are done.

    Just have to remember the file controls the directory it is in AND every file/directory below it. If you want something different in a directory below the first one THEN you will add a second.

    EXAMPLE: yoursite.com/members_area/ <~~ here you have a .htaccess that blocks 3 IPs, asks for a password and redirects to yoursite.com/members_area/logged_in.php

    However, you don't want ANYONE to see the directory at yoursite.com/members_area/private_junk/ so inside the /private_junk/ directory you will add a SECOND .htaccess that simply is coded as:

    Code:
    Deny from all
    See the idea?
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

Bookmarks

Posting Permissions

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