-
.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
-
-
.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
-
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
-
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:
See the idea?