homepage Welcome to WebmasterWorld Guest from 54.237.249.10
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

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
slmandle




msg:3384160
 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>

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

 

jdMorgan




msg:3384361
 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
</Directory>
#
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.

Jim

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