Project

General

Profile

MigratingFromApache » History » Revision 4

Revision 3 (jan, 2005-07-05 22:12) → Revision 4/51 (jan, 2005-07-05 22:16)

== Basic Options == 

 {{{ 
 Options +FollowSymLinks 
 }}} 

 becomes 

 {{{ 
 server.follow-symlinks = "enable" 
 }}} 

 == mod_rewrite == 

 [http://www.lighttpd.net/documentation/rewrite.html mod_rewrite] is more trickier as the idea how it is handled is completly different. 

 First of all we always match on the full relative request-uri that is submitted by the user. That means that we are always using the [QSA] flag from mod_rewrite in Apache. 

 This is example is based on a problem taken from http://dir.onlinesearch.ws/ sent in by dbird@freenode. (thanks to dbird@freenode) 

 {{{ 
 RewriteEngine On 
 RewriteBase /installdir/ /instadir/ 
 RewriteCond %{REQUEST_FILENAME}    -d 
 # Fix trailing slash problem 
 RewriteRule ^(.+[^/])$             $1/    [R,L] 
 # Do not try to treat the following resources as parameters to index.php 
 RewriteRule ^index.php.*$         - [L] 
 RewriteRule ^dmoz.css$            - [L] 
 RewriteRule ^admin[/]?.*$         - [L] 
 RewriteRule ^img[/]?.*$           - [L] 
 RewriteRule ^[/]{0,}(.*)$ index.php?area=browse&cat=$1 [QSA,L]  
 }}} 

 These rewrites want to rewrite everything that is not the index.php, dmoz.css, admin-interface or something from the image-directory to a parameter of the index.php page. The base directory for this match is ''/installdir/'' 

 {{{ 
 ## for all URLs in /instadir/ that are not index.php, dmoz.css, admin or img, do ... 
 $HTTP["url"] =~ "^/installdir/(?!index.php|dmoz.css|admin|img)" "^/instadir/(?!index.php|dmoz.css|admin|img)" { 
   url.rewrite = ( "^/installdir/(.*)" "^/instadir/(.*)" => "/installdir/index.php?area=browse&cat=$1") "/instadir/index.php?area=browse&cat=$1") 
 } 
 }}} 

 The conditional is using some from regex-magic called [http://perlpod.com/5.9.1/pod/perlre.html#Extended%20Patterns zero-width negative look-ahead assertion] and is something from the advanced advance chapters of your [http://www.oreilly.com/catalog/regex/ regex book]. book.