Forum Moderators: phranque

Message Too Old, No Replies

Deny acces to a file

using .htacces

         

malasorte

12:44 pm on Jan 22, 2006 (gmt 0)

10+ Year Member



Hello all,

How can I deny acces to a file (for example robots.txt or private.html) to all of the people that visit my site? Is there a way to do this using .htacces?

Thanks!

Frank_Rizzo

2:38 pm on Jan 22, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That seems a strange request - to deny a file to everyone.

The simplest soultion is to just delete the file!

The second simplest is to change the rights of the file so no one can see it.

chmod 0 secretfile.html

It can be done with htaccess but if the above methods are what you are looking for then try them first.

extras

4:14 pm on Jan 22, 2006 (gmt 0)

10+ Year Member



There are several ways:

You can use <Files ...> directive and deny from all.
<Files "sample.html">
deny from all
</Files>

You can use RewriteRule.
RewriteRngine on
RewriteRule ^example.html$ - [F]

You can set the permission to 600 (this works on most servers).

You can rename files.
You can move files to another directory without public access.