homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

Apache allow directory browsing from ip
Apache allow directory browsing from ip

5+ Year Member

Msg#: 3384158 posted 1:42 pm on Jul 2, 2007 (gmt 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



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

Msg#: 3384158 posted 5:48 pm on Jul 2, 2007 (gmt 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.


Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved