Permanent redirect (301) with lighttpd

If you want to redirect visitors that access your website without the ‘www’, you can use mod_redirect with the following syntax:

$HTTP[”host”] =~ “^lescampeurs\.org” {
    url.redirect = (
        ”^/(.*)$” => “http://www.lescampeurs.org/$1″
    )
}

Links:

Comments (3)

  1. Thanks for the tips,

    just to notice, if you like more redirection you need to use +=

    example:

    $HTTP[”host”] =~ “^lescampeurs\.org” {
    url.redirect = (
    ”^/(.*)$” => “http://www.lescampeurs.org/$1″
    )
    url.redirect += (
    ”/oldpage/shall/301/redirect” => “http://www.lescampeurs.org/newpage″
    )
    }

    Wednesday, January 27, 2010 at 11:37 am #
  2. CharlyBr wrote::

    Thanks for this one, didn’t know it :)

    Tuesday, February 2, 2010 at 10:50 am #
  3. pSub wrote::

    There’s an easier way to do multiple redirects: Just comma separate them!

    $HTTP[”host”] =~ “^lescampeurs\.org” {
    url.redirect = (
    ”^/(.*)$” => “http://www.lescampeurs.org/$1″,
    ”/oldpage/shall/301/redirect” => “http://www.lescampeurs.org/newpage″
    )
    }

    Friday, October 14, 2011 at 11:29 pm #