Project

General

Profile

HowToAllowAccessToOnlyCertainFileTypes » History » Revision 3

Revision 2 (Anonymous, 2006-10-18 20:27) → Revision 3/4 (Anonymous, 2006-10-18 20:27)

h2. == How To Allow Access to only Certain File Types 


 == 

 It is easy in lighttpd to deny access to a few types of files using mod_access: 


 <pre> 

 

 {{{ 
 url.access-deny = ( "~", ".inc") 
 </pre> 


 }}} 

 But what if you want to allow access to only a few types of files, and deny access to all others?    In the example below, we allow access to common static file types, and deny access to all other files: 


 <pre> 

 

 {{{ 
 $HTTP["url"] !~ "\.(jpg|gif|png|ico|js|css)$" { 
   url.access-deny = ( "" ) 
 } 
 </pre> 


 }}} 

 This will cause all URLs that don't match the pattern to be denied.    Note that all non-matching URLs will return 403 Forbidden, non-existent files will not return 404 Not Found.