[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

block access to htaccess

Posted on 2014-08-14
7
Medium Priority
?
189 Views
Last Modified: 2014-08-14
If I have multiple htaccess files in root directory and I wish to block access to all htaccess files, do I put below code in all three htaccess files or will putting code in just the one htaccess file at the top of the root directory hierarchy protect the other htaccess files that sit in sub-directories to that top htaccess file?

<Files .htaccess>
      order allow,deny
      deny from all
</Files>
0
Comment
Question by:kadin
  • 3
  • 3
7 Comments
 
LVL 84

Accepted Solution

by:
Dave Baldwin earned 600 total points
ID: 40262354
That is normally in your 'apache2.conf' or your 'httpd.conf' file on your server to prevent anyone from viewing or downloading your '.htaccess' files.  You shouldn't have to put that in an '.htaccess' file itself.

In addition, this page http://httpd.apache.org/docs/2.2/mod/core.html#accessfilename says that Apache will only read the first '.htaccess' file it find and ignore the others.
0
 
LVL 23

Assisted Solution

by:tailoreddigital
tailoreddigital earned 400 total points
ID: 40262360
Files starting with a "." on Unix/Linux systems are not publicly visible.    Like Dave just pointed out, you don't have to put that in the htaccess file, they should not be visible by default.
0
 

Author Comment

by:kadin
ID: 40262365
I am using a shared server. I have not checked but I assume I do not have access to apache2.conf or httpd.conf.

I have more than one htaccess file for other purposes like mode rewrite and another htaccess to protect a file upload folder. The htaccess must be in that folder and cannot be at the top of the directory where the first htaccess is. Your not trying to say apache will ignore all my htaccess files I think. But rather just the duplicate code in all htaccess files if any. Wright?
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 

Author Comment

by:kadin
ID: 40262367
Thanks Tailor. I read that this would be an added security measure,  that's why I am doing it.
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 40262407
Apache will only open the first '.htaccess' file it finds in each directory in the path.  Each directory that needs it should have only one '.htaccess' file.
0
 

Author Comment

by:kadin
ID: 40262424
Great. Thanks for your help Dave.
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 40262439
You're welcome.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I made this because I wanted to get e-mail with a attached csv file so I'd would be able to import user input into a MS Excel template, but I also wanted to register/save all inputs from each day in a file on the server. 1st - It creates a temp C…
In this article you will learn how to create a free basic website on Bitbucket, a git service provider. Polymer creates dynamic HTML components, which allow more flexibility than static HTML. This tutorial uses Ubuntu Linux but can also be done on W…
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Suggested Courses
Course of the Month17 days, 23 hours left to enroll

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question