views:

72

answers:

1

Let me explain my situation:

I'm using a MVC framework (CodeIgniter), so every request gets rewritten to my index.php file, which in turn routes this to my classes and functions.

Offcours if there are requests for real files they should not be processed by scripts but directly send from webserver to browser.

Owkay no problem, the following rewrite rules will do just that:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

I would like that requests for a certain folder (let call it 'private') still be processed by php. The reason for doing this is that i would then verify if the user is authenticated, and if so, send contents to browser.

  • Any apache gurus in the house who can assist?
  • Is this a acceptable solution to this the problem?
+1  A: 

Try this rule:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d [OR]
RewriteCond $1 ^private($|/)
RewriteRule ^(.*)$ index.php/$1 [L]

This will exclude any URL paths that are private or start with private/ even though they are existing folders or files.

Gumbo
hm strangely enough this doens't seem to work... the request doesn't get rewritten... any advice? thanks anyway! ;-)
Sander Versluys
@Sander Versluys: Fixed it.
Gumbo
Allright! Thanks, this got me on the right track! ;-) Based on your anwser, I moved the [OR] to the rewrite condition for files and disabled directory listing, thus 'securing' the files by whatever logic put in my scripts... txn!
Sander Versluys