Book Image

Lighttpd

By : Andre Bogus
Book Image

Lighttpd

By: Andre Bogus

Overview of this book

Table of Contents (20 chapters)
Lighttpd
Credits
About the Author
About the Reviewer
Preface
HTTP Status Codes

Rewriting Rules


On the Lighttpd forums, most former Apache administrators ask how they can adapt their rewrite rules to work with Lighttpd. There is no program (yet) to do this, but here are some typical constructs and advice on how to do that in Lighttpd lingua:

Apache

Lighttpd

LoadModule "rewrite_module"

RewriteEngine on

server.modules = (..., "mod_rewrite",

"mod_redirect", ...)

# A simple rewrite

RewriteRule ^from_here(.*)/to_there$1

# refer to Chapter 2

url.rewrite = ("^/from_here" => "to_there")

RewriteCond %{HTTP_HOST} me\..*

RewriteRule ^/(.*) /me/$1

$HTTP["host"] =~ "me\..*" {

url.rewrite = ( "^/" => "/me/"

}

# Redirecting a single file

RewriteRule move.html target.html [R]

url.redirect = ( "move.html" => "target.html")

# Solving the trailing slash problem

RewriteCond %{REQUEST_FILENAME} -d

RewriteRule (.*) $1/

# nothing to do here. Lighttpd does not

# have this problem.

# Redirecting failed web pages to xyz.com

RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule...