views:

248

answers:

1

Hi there,

I have a directory structure like so:

directory1
- directory2
- <other files I want to be hidden>

I want to allow the user access to directory 2, but disallow access to directory 1. For example:

http://website/directory1 = 404 / Forbidden

http://website/directory2 = Routes to directory1/directory2 and shows files.

I managed to lock out directory1 by using this code:

RewriteRule ^(directory1) - [F,L]

But this obviously applies to subdirectory too and doesn't really help matters!

Any suggestions would be greatly appreciated, I've been pulling my hair out of this one.

A: 

I think something like this may work. Although admittedly, I have some troubles with mod_rewrite as well,

RewriteCond %{REQUEST_FILENAME} ^directory1
RewriteRule !^directory1/directory2 - [F,L]

or possibly, if mod_rewrite can handle these types of regexps, where (?! ) is a non-matching group,

RewriteRule ^directory1(?!/directory2) - [F,L]
Mike Nelson