21 Jan, 2009 in Apache by admin

How To Grant/Deny Access to Particular Web Files Using Apache

When browsing web and directory, most bots, without consideration to .htaccess restrictions, have the capability to crawl and sniff and folders located under your web folder, even if these and folders were not visually displayed from your web pages.

Take for an example, you displayed a file under http://domain.com/folder1/folder2/folder3/page.html

Most bots would initially crawled for targetted page file http://domain.com/folder1/folder2/folder3/page.html and later on would schedule a secondary deep crawl for possible under

http://domain.com/folder1/folder2/folder3/

http://domain.com/folder1/folder2/

http://domain.com/folder1/

You could actually see bots coming back and forth to your computer host and start crawling subfolders and subpages of your public .

There are a lot of approach on how to deny access to particular web pages from being accessed and viewed from web. This entry covers an approach on how to use Apache directives to deny access to web or particular set of file extensions from being viewed and browse by web clients

Basic Requirements

a. Existing Apache Setup On Linux Platform

Here are the following steps

Steps One

For example, we want to deny browse access to all ending in XYZ (*.XYZ) using Apache directives.

Backup and modify your /etc/httpd/conf/httpd.conf . Search and look for the line

AccessFileName .htaccess

< ~ “^\.ht”>
Order allow,deny
Deny from all
</>
Steps Two

To deny access to web clients from viewing all with XYZ file extensions (*.ZYZ), simply append similar lines like so

< ~ “^\.xyz”>
Order allow,deny
Deny from all
</>

Modify xyz to suit your file extension needs.

To deny access to particular file, simply

< ~ “private-file.txt”>
Order allow,deny
Deny from all
</>

Steps Three

Save and exit /etc/httpd/conf/httpd.conf . Restart HTTPD daemon service

# service httpd restart

Test your new Apache setup

# elinks http://domain.com/folder1/folder2/folder3/page.xyz

# elinks http://your-domain.com/yourpage.XYZ

All done.

Bookmark This

No Responses so far | Have Your Say!

Leave a Feedback

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>