php - .htaccess, use mod_rewrite to rewrite to a file OUTSIDE the web root -


here representation of directory structure:

/var/www   /html/site     .htaccess   /secret     file.php 

i'd use .htaccess file rewrite url requests made http://example.com/files/1234 code file.php sitting outside of webroot. security reasons, other developers i'm working insistent code sit outside of web accessible directories. far, .htaccess file looks this:

rewriteengine on rewriterule ^files/(.*)$ ../../secret/file.php?file_name=$1 [nc,l] 

but i'm getting 400 bad request when try this. possible?

short answer: no. webserver can't directly access files outside of document root. if think it, there quite security problem if could. can rewrite file within document root includes or reads file located outside of root. (moved comments...)


Comments