I'm doing the following:

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/public
RewriteRule /(.+) /public/$1

And it maps like this:

/           => index
/.+         => /public/$1
/public/.*  => Doesn't map, but it should map to /public/public/$1

I don't wan't /public/ to be accessible, how can I do that?

link|improve this question

60% accept rate
So you want them to be able to be rewritten to it but not access it directly? What problem could that possibly solve? – MDMarra Nov 12 '11 at 12:07
Being able to have a file named public in the public directory and be accessed from the root. – Zequez Nov 12 '11 at 17:13
feedback

1 Answer

Just write, as the #1 rule :

RewriteRule /public/(.*) - [F,L]

Then if someone wants to access to /public/ there will be a FORBIDDEN. After this rule, you may apply your rules.

;)

So your rules may look like:

RewriteEngine On
RewriteRule /public/(.*) - [F,L]
RewriteCond %{REQUEST_URI} !^/public
RewriteRule /(.+) /public/$1
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.