Mod redirect » History » Revision 19
« Previous |
Revision 19/36
(diff)
| Next »
heavyhttpd, 2009-01-11 03:08
clarify meaning of %1
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" ) }
Note that the "%1" in the url.redirect target refers to the parenthesized subexpression in the conditional regexp (.*). It does not necessarily have the meaning that "%1" would have in evhost.path-pattern (where it would mean 'top-level domain').
url.redirect-code (Added in 1.5.0)¶
Defines the http code that is sent with the redirect URL
e.g.
url.redirect-code = 302
Example¶
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" ) }
Moving any subdomains except a few to www.example.org: (Note: The second match is required since a non-match doesn't set any groups) ::
$HTTP["host"] !~ "^(www|mail|mysql)\.(example\.org)$" { $HTTP["host"] =~ "^(.+\.)?(example\.org)$" { url.redirect = ( "^/(.*)" => "http://www.%2/$1" ) } }
Updated by heavyhttpd almost 16 years ago · 19 revisions