Disable access to .htaccess

Reply

Join Date: Feb 2002
Posts: 12,027
Reputation: cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light 
Solved Threads: 126
Administrator
Staff Writer
cscgal's Avatar
cscgal cscgal is online now Online
The Queen of DaniWeb

Disable access to .htaccess

 
0
  #1
Jul 11th, 2003
What can I do to disable public downloading of my .htaccess file? I am on a Linux box. I can't chmod the file because the web browser still needs access to it, obviously. I know that there is a line I can add to it so that it gives the user a 403 Permission Denied error upon directly accessing it, but I don't remember what it is. Anyone know?
Dani the Computer Science Gal
Follow my Twitter feed! twitter.com/daniweb
Reply With Quote Quick reply to this message  
Join Date: Dec 2002
Posts: 2
Reputation: treydawg is an unknown quantity at this point 
Solved Threads: 0
treydawg treydawg is offline Offline
Newbie Poster

Re: Disable access to .htaccess

 
0
  #2
Jul 12th, 2003
To prevent viewing of htaccess files use:

<Files .htaccess>
order allow,deny
deny from all
</Files>



and to prevent directory listing try:

IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*


Trey B.
Web Hosting Support
Reply With Quote Quick reply to this message  
Join Date: Feb 2002
Posts: 12,027
Reputation: cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light 
Solved Threads: 126
Administrator
Staff Writer
cscgal's Avatar
cscgal cscgal is online now Online
The Queen of DaniWeb
 
0
  #3
Jul 12th, 2003
Hey there! Thanks! Helpful as always.
Dani the Computer Science Gal
Follow my Twitter feed! twitter.com/daniweb
Reply With Quote Quick reply to this message  
Join Date: Feb 2002
Posts: 12,027
Reputation: cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light 
Solved Threads: 126
Administrator
Staff Writer
cscgal's Avatar
cscgal cscgal is online now Online
The Queen of DaniWeb

Re: Disable access to .htaccess

 
0
  #4
Jul 12th, 2003
I came across a cleaner way.

RewriteRule ^\.htaccess$ - [F]

The [F] means to make the file forbidden.
Dani the Computer Science Gal
Follow my Twitter feed! twitter.com/daniweb
Reply With Quote Quick reply to this message  
Join Date: Feb 2002
Posts: 12,027
Reputation: cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light 
Solved Threads: 126
Administrator
Staff Writer
cscgal's Avatar
cscgal cscgal is online now Online
The Queen of DaniWeb

Re: Disable access to .htaccess

 
0
  #5
Jul 12th, 2003
Oops! Just remembered the rewrite rule (using mod_rewrite) won't work unless the rewrite engine is turned on. So the code in .htaccess has to look something like this

RewriteEngine on
RewriteRule ^\.htaccess$ - [F]
Dani the Computer Science Gal
Follow my Twitter feed! twitter.com/daniweb
Reply With Quote Quick reply to this message  
Join Date: Dec 2002
Posts: 2
Reputation: treydawg is an unknown quantity at this point 
Solved Threads: 0
treydawg treydawg is offline Offline
Newbie Poster

Re: Disable access to .htaccess

 
0
  #6
Jul 13th, 2003
Unfortunately, all rewrite directives can be in the .htaccess except one.

RewriteEngine On must be in the httpd.conf of the server and not in the htaccess. Plus if you use rewrite there will be a performance penalty compared to just denying the file.

Just FYI, hope that helps.

Trey
Reply With Quote Quick reply to this message  
Join Date: Feb 2002
Posts: 12,027
Reputation: cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light 
Solved Threads: 126
Administrator
Staff Writer
cscgal's Avatar
cscgal cscgal is online now Online
The Queen of DaniWeb

Re: Disable access to .htaccess

 
0
  #7
Jul 13th, 2003
Hey, thanks. I thought of that one because I've been dealing with .htaccess and mod_rewrite, where it is required to put RewriteEngine on into .htaccess. Check out my post about mod_rewrite and google located here: http://www.daniweb.com/forums/thread653.html
Dani
Dani the Computer Science Gal
Follow my Twitter feed! twitter.com/daniweb
Reply With Quote Quick reply to this message  
Join Date: Feb 2002
Posts: 12,027
Reputation: cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light 
Solved Threads: 126
Administrator
Staff Writer
cscgal's Avatar
cscgal cscgal is online now Online
The Queen of DaniWeb

Re: Disable access to .htaccess

 
0
  #8
Jul 13th, 2003
BTW Yes, I've heard that mod_rewrite has a big performance hit to the cpu
Dani the Computer Science Gal
Follow my Twitter feed! twitter.com/daniweb
Reply With Quote Quick reply to this message  
Join Date: Jan 2005
Posts: 14
Reputation: wfwh is an unknown quantity at this point 
Solved Threads: 0
wfwh wfwh is offline Offline
Newbie Poster

Re: Disable access to .htaccess

 
0
  #9
Jan 4th, 2005
Can you not chmod the file to 700? i think that still allows the file to be read
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 42
Reputation: YUPAPA is an unknown quantity at this point 
Solved Threads: 0
YUPAPA's Avatar
YUPAPA YUPAPA is offline Offline
Light Poster

Re: Disable access to .htaccess

 
0
  #10
Jan 9th, 2005
Originally Posted by wfwh
Can you not chmod the file to 700? i think that still allows the file to be read
Depending on the ownership of the .htaccess file, if you change permission to 0700 when the ownership of the file is owned by apache (or http, nobody, depending the user running apache), it may work ~

Otherwise, it gives you a forbidden error.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Linux Servers and Apache Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC