My Web Hosting Manual


Home > .htaccess > Prevent Viewing Of .htaccess File

Prevent Viewing Of .htaccess File

So you're learning how to do a bunch of nifty things with your .htaccess file. Great. But now you need to protect it from everyone so they can't see it. Specially if you use .htaccess with .htpasswd. If people can see the .htaacess, they can see where your .passwd file is located. That's not good.

But we can prevent this too. Just include this into your .htaccess file and no one will be able to see it!

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

The first line specifies that the file named .htaccess will be denied if anyone tried to see it.

The peron will get a "403 error code". Show them something interesting, affiliate links, or sell them something. We already learned how to change error documents.

As an added measure of security, you can chmod the .htaccess file to 644 or rw-r--r--

Review It

You might also be interested in:






Top Hosting
  - Host Gator
  - Host Monster
  - Blue Host
  - Easy CGI
  - Lunar Pages
       
All content has been created by Juan Carlos Gorospe. These are my opinions and experiences.
Copyright © 2008, Juan Carlos Gorospe. All Rights Reserved.