List Info

Thread: question about conditional document roots




question about conditional document roots
country flaguser name
Germany
2007-10-01 13:48:11
Hey guys,

I'm just transfering my Apache site onto lighty and don't
have enough 
knowledge about regular expressions to achieve what the '*'
in Apache 
did for me.
First of all, here is what I want to achieve:

kilu.de & www.kilu.de & kilu2.de ... ->
/var/www/site
blog.kilu.de -> /var/www/blog
*.kilu.de (but not matching the urls defined above) ->
/var/www/error

Here is what I got:
$HTTP["host"] =~ 
"^(kilu.de|www.kilu.de|kilu2.de|www.kilu2.de|kilu
3.de|www.kilu3.de)$" 
{
        server.document-root = "/var/www/site/"
}


$HTTP["host"] =~ "^blog.kilu.de$" {
        server.document-root = "/var/www/blog/"
}

$HTTP["host"] =~ "^( ...???...
)(.kilu.de|.kilu2.de|.kilu3.de)$" {
        server.document-root = "/var/www/error/"
}

I do unfortunately do not know what would go into the last
regexp. I 
guess I'd have to exclude "blog","www"
and "" (empty) somehow, but how 
do I do that?

Any help would be appreciated!

Regards,
Samy


Re: question about conditional document roots
country flaguser name
Germany
2007-10-01 14:37:27
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Heya,

> Big Thanks for pointing out the else statement to me!
lighttpd 
> configuration seems a lot more thought through then
apache's ;)
> Now, when I want to the first directive to also match a
different 
> domain, for example "foo.de" how would I ad
that to the regexp?
[...]
> > Just use "else" in front of all
conditionals (except first), i.e.
> > $HTTP["host]" =~
"^(www.)?kilu[23]?.de$"  {
> > ...
> > } else $HTTP["host"] ==
"blog.kilu.de" {
> > ...
> > } else $HTTP["host"] =~
"kilu[23]?.de$" {
> > ...
> > }
$HTTP["host"] =~
"^(www.)?(foo|kilu[23]?).de$" if you want
www.foo.de
as well
or
$HTTP["host"] =~
"^((www.)?kilu[23]?|foo).de$" if you only want
foo.de.
http://pcre.org/pcre.txt
might help in the future :p

Also, it seems you sent the reply directly to me; usually
you should CC
the list address (or just use the reply-to-all feature of
your mail
client). ;)

- -- 
Christian Hoffmann
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)

iD8DBQFHAUx3J9KLJlGHWYIRAmbtAKCDl1YJCsu8X/7kLS/W9NC05an3QgCc
DDMW
9QlRtSqh35JqMu8l2AmZS98=
=r9Aa
-----END PGP SIGNATURE-----
Re: lighty not displaying umlauts
country flaguser name
Germany
2007-10-02 11:43:30
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

> We successfully migrated kilu.de to lighty, but there
is still one 
> pending problem:
> 
> Lighty does not display our German umlauts and Google
does not want
> to tell me how to change that.
> In Apache we achieved this by adding
"AddDefaultCharset ISO-8859-1"
> to our configuration. How about lighty?
You can force a charset by using mimetype.assign:
mimetype.assign = (
...
	".html" => "text/html;
charset=utf-8"
...
)
Make sure you don't overwrite any previous mimetype
definitions. Also,
this will only work for files which are handled by lighttpd,
it will
NOT work for anything else (*cgi). For that case you should
fix your
app to output the correct charset in the first place.

For PHP you might want to have a look at the ini option
default_charset
(which doesn't force a charset but only provides a default;
if you
overwrite it from within your code it's your fault ;)).

- -- 
Christian Hoffmann
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)

iD8DBQFHAnUyJ9KLJlGHWYIRAnlHAJ9rFmH/10blrEJyihNaGraovbT9vACe
InDt
oizZrYDnwpx/lUHQJP/hdj8=
=FZZa
-----END PGP SIGNATURE-----
Re: lighty not displaying umlauts
country flaguser name
Germany
2007-10-02 12:12:20
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

> Now I have another questions. Our error page is located
at 
> "error.kilu.de". I managed to send all 404s
to this page by adding
> the following to lighty's config:
new question, new thread please ;)


> server.error-handler-404  = "/error"
> url.redirect = ( "^/error$" => "http://error.kilu.de/&quo
t; )
> 
> This works pretty well, but now the error page send
stauts code 200
> and not 404. In Apache I fixed this using a header()
PHP call, but
> this doesn't work in lighty, does it?
> How would I achieve sending an 404?
Sending the appropriate header from a *CGI script should
work in lighty
as well. Either
	HTTP/1.1 404 Not found
or
	Status: 404 Not found
should work (maybe even both).

- -- 
Christian Hoffmann
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)

iD8DBQFHAnv0J9KLJlGHWYIRAoTZAJ9K2iBTlHzWe4bN9gwc1+uFf2aqkACg
0DLV
3rvFy7UazFORAm3XKCDsHiw=
=m/iI
-----END PGP SIGNATURE-----
[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )