Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Apache allow directory browsing from ip

Apache allow directory browsing from ip

1:42 pm on Jul 2, 2007 (gmt 0)

New User

5+ Year Member

joined:July 2, 2007
votes: 0

I have a directory which I would like to allow directory browsing to internal clients only but still allow the external world to see it without being able to browse my dir structure

I am trying to achieve soemthing like below, obviously the below doesn't work as the last Directory statement is the one used

# allow directory browsing from the internal network
<Directory /var/www/template>
Options Indexes
allow from #*$!.#*$!.#*$!.xx

<Directory /var/www/template>
Options -Indexes

5:48 pm on July 2, 2007 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
votes: 0

I don't know of a direct way to do this. However, you can enable indexes for everyone, and then divert external index requests to a "page" so that the index won't be shown. Either "/index.html" or "/" is considered to be a match for this rule as shown.

In httpd.conf:

<Directory /var/www/template>
Options Indexes FollowSymLinks
RewriteEngine on
# If request is not from an internal network address,
# rewrite any directory index request to an html page
RewriteCond %{REMOTE_ADDR} !^192\.168\.
RewriteCond %{REMOTE_ADDR} !^10\.
RewriteCond %{REMOTE_ADDR} !^127\.0\.0\.1$
RewriteRule ^/(index\.html)?$ /index_page_for_external_visitors.html [L]

The index page for external visitors could be either an existing page or a new page with an explanatory message, a link to the "proper" URL for them to use to enter the site, and possibly a meta-refresh to that proper entry point after sufficient time to allow them to read and comprehend the explanatory message.