I want to redirect all non-www to www on my domain.
But when I use this code provided by some websites, and do a graceful restart of the lighttpd server, my website doesn't function anymore – at all:
$HTTP[”host”] =~ “^example\.com” {
url.redirect = (
”^/(.*)$” => “http://www.example.com/$1″
)
}
But when I use the one provided at lighttpd's wikipedia page, it works, but it redirects everything example.com/ANYTHINGHERE to www.example.com, i.e. example.com/search.php?v=michael is redirected to www.example.com:
$HTTP["host"] =~ "^([^.]+\.[^.]+)$" {
url.redirect = (
".*" => "http://www.%1"
)
}
I have remembered to include mod_redirect in the config file. Can anyone help me? 🙂
Best Answer
In the first example you are messing with all type of quotation marks. Only
" "
, "programmer’s" quotes, are recognized as quotes in configuration files. You configuration now has curved quotes (”, “) and even Chinese style prime quotation mark (″).You could try this