2007-10-18

Enabling CakePHP 1.1 on Lighttpd 1.5

A lot of people out there are trying to figure out how to get CakePHP 1.1x running on Lighttpd 1.5. Here is the solution. Please follow it carefully:
#### Disable BASE_URL ####

 a) Open the file "app/config/core.php"
 b) Make sure that the BASE_URL constant is commented out
 
#### REDIRECT_URI fix ####

 a) Open the file "cake/basics.php"
 b) Go to the function "setUri"
 c) Find this line:

   if (env('HTTP_X_REWRITE_URL')) {
    
  Replace with this:
  
   if( env('REDIRECT_URI') ) {
    $uri = env('REDIRECT_URI');
   }
   else if (env('HTTP_X_REWRITE_URL')) {

#### Add rewrite rules to lighttpd.conf ####

 a) Enable mod_rewrite in lighttpd.conf
 b) Add this to lighttpd.conf:

   url.rewrite-once = (
    "^/(css|files|img|js|stats)/(.*)$" => "/$1/$2",
    "^/(.*)$" => "/index.php?url=$1"
   )