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:

 
  • 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″
    )
    }

  • CharlyBr

    Thanks for this one, didn’t know it 🙂

  • 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″
    )
    }

  • Pingback: Aprende a hacer bien la migración de un sitio Web - SISTRIX()