I've the next directory structure in htdocs:


I am attempting to achieve clean Web addresses and essentially want everything routed through index.php. My .htaccess file is the following:

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f # <- referring to this next
RewriteRule .* index.php [L]

This is effective meaning will be able to access legitimate files within foo/ and bar/ directly, however I am also in a position to access files in priv/ that is what I wish to disallow. How do you customize the above recommended line to essentially say: "disable for files that aren't in priv/"?

EDIT: I am attempting to avoid needing to do "priv/.htaccess" -> "deny from all", and rather want to process this in index.php like every other "pretty url" conversion.

You can include another RewriteCond using the condition simply to match ^priv/ and mix it with OR:

RewriteCond $0 ^priv/ [OR]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* index.php [L]

This rule is used if either the matched up partial path begins with priv/ or when the request can't be planned onto a current file.