[chuug] Apache config question

Alok Singhal as8ca at virginia.edu
Tue Apr 17 13:35:35 EDT 2007


On 13/04/07: 14:24, David Sewell wrote:
> Can any Apache configuration gurus tell me:
> 
> Is it possible to configure a directory so that a directory index is
> viewable by some users and not others? For example, for connections from
> .virginia.edu, set
> 
>    Options +Indexes
> 
> but for all other connections set
> 
>    Options -Indexes

Here is another way to go about it.  Since I couldn't test it on a
running server by editing its httpd.conf file, I have done it using
the .htaccess method.  You will need mod_rewrite for this to work.

Assuming the directory you wish to change is "/local/" on your
webserver running at http://host.domain, in the .htaccess file in
/local, have something like

RewriteEngine On
RewriteBase /local
RewriteCond %{REMOTE_HOST} !virginia.edu$
RewriteRule ^$ http://host.domain/noaccess/

The /noaccess directory has "Options -Indexes" in the config file, and
/local as "Options +Indexes".

As an aside, I tried changing the last line in the above rule to

RewriteRule ^$ /noaccess

and even

RewriteRule ^$ ../noaccess

but it returns with "The server made a boo boo" (error 500), so I had
to change to rule to include the complete URL.

HTH,
Alok

-- 
Alok Singhal                               *   *          
Graduate Student, dept. of Astronomy   *           *     *
University of Virginia                                    
http://www.astro.virginia.edu/~as8ca/              *    * 


More information about the Chuug mailing list