lighttpd forum lighty > rewrite a subdomain...

Posted by N0k N0k
on 04.09.2008 07:59
Hello.

im getting problem trying configure a rewrite rule for a subdomain.
I want a rewrite rule for everysubdomain but www, something like:

subdomain1.domain.tld => index.php?categoy=subdomain1

But this is not necesary for www subdomain:

www.domain.tld => index.php

Im trying this:

"^([a-z]+)\." => "/index.php?categoria=$1"
or
"^([a-z]+)\." => "/index.php?categoria=%3"

But not run :(

any help ?
Posted by N0k N0k
on 04.09.2008 09:02
Im progresing:

$HTTP["host"] =~ "^([^.]+)\.domain\.com" {
        server.document-root = "/var/www/test/"
        url.rewrite-once = ( "^/(.*)$" => "/index.php?category=%1" )
}

But this is for every subdomain, how could i exclude www ?
Posted by N0k N0k
on 04.09.2008 09:24
I  did :)
im not sure if is the perfect solution but it works:

$HTTP["host"] !~ "^(www)\.domain\.com" {
        $HTTP["host"] =~ "^([^.]+)\.domain\.com" {
                server.document-root = "/var/www/test/"
                url.rewrite-once = (
                "^/(.*)$" => "/index.php?category=%1"
                )
        }
}

$HTTP["host"] =~ "^(www)\.domain\.com" {
        server.document-root = "/var/www/test/"
}

First i exclude www, and after, i declare it. Maybe is better, firs www 
and then exclude, because www get more traffic than others.