Search code examples
httpd.conflighttpd

Lighttpd redirect


I am re-jigging my website and would like to redirect (not rewrite but not hang up on this) the majority of requests to *.php files to their equivalent *.html files.

I have placed all the files I do not want redirected in one folder aptly named excluded, so I can filter the redirect rule on that folder. Here's what I have in my lighttpd.conf file:

$HTTP["url"] !~ "^/excluded/" {
  $HTTP["url"] =~ "^(.*)\.php(.*)" {
    # this is where I want the redirect rule
  }
}

EDIT: I am not sure whether I am missing a $ at the end of the second conditional rule (or whether the ending (.*) is necessary), but I suppose that is where I'd like help with.


Solution

  • $HTTP["url"] !~ "^/excluded/" {
      url.redirect = ( "^(.*)\.php(.*)" => "$1.html$2" )
    }