Project

General

Profile

Mod redirect » History » Revision 10

Revision 9 (Anonymous, 2006-12-16 12:53) → Revision 10/36 (alexlehm, 2007-02-26 21:35)

{{{ 
 #!rst 
 =============== 
 URL Redirection 
 =============== 

 -------------------- 
 Module: mod_redirect 
 -------------------- 

 .. meta:: 
   :keywords: lighttpd, redirect 
  
 .. contents:: Table of Contents 

 Description 
 =========== 

 The redirect module is used to specify redirects for a set of URLs. 

 Options 
 ======= 

 url.redirect 
   redirects a set of URLs externally 
  
   e.g. :: 
  
     url.redirect = ( "^/show/([0-9]+)/([0-9]+)$" => "http://www.example.org/show.php?isdn=$1&page$2", 
                      "^/get/([0-9]+)/([0-9]+)$"    => "http://www.example.org/get.php?isdn=$1&page$2" ) 

     # make an external redirect 
     # from any www.host (with www.) to the host (without www.) 
     $HTTP["host"] =~ "^www\.(.*)$" { 
       url.redirect = ( "^/(.*)" => "http://%1/$1" ) 
     } 

 Some people love the www part in the url. A general solution to move all non www. hosts to its www equivalent: :: 

     $HTTP["host"] =~ "^([^.]+\.[^.]+)$" { 
       url.redirect = ( 
         ".*" => "http://www.%1$0" 
       ) 
     }  

 Moving any subdomains except a few to www.example.org: (Note: The second match is required since a non-match This doesn't set any groups) seem to work, anyone who can fix it, please do!) :: 

     $HTTP["host"] !~ "^(www|mail|mysql)\.(example\.org)$" { 
       $HTTP["host"] =~ "^([^.]+)\.(example\.org)$" { 
         url.redirect = ( 
           
         "^/(.*)" => "http://www.%2/$1" 
         
       ) 
       } 
     }  

 }}}