Project

General

Profile

Solved: rewrite problem

Added by blupp over 15 years ago

It is certainly a problem of misunderstanding, but someone should give me a hint :-).
I use lighttpd lighttpd 1.4.19 under Debian Lenny and I can´t get to work a rewrite rule for changing the string

'/tag/?t=xyz' to '/tag/xyz'

I tried the following rewriterule

url.rewrite-once = (
"^/tag/\?t=(.*)$" => "/tag/$1/",
)

but it doesn´t work.
The rewriterule is in the serverconfigfile in /etc/lighttpd/conf-enabled, but somehow nothing happens.
Any hint?
Thank you a lot!

Serverconfig says:
---------------------------
Server-Features
RegEx Conditionals enabled
Network Engine
fd-Event-Handler linux-sysepoll
Config-File-Settings
Loaded Modules
indexfile
access
alias
accesslog
rewrite
redirect
status
compress
rrd
auth
fastcgi
dirlisting
staticfile


Replies (5)

RE: rewrite problem - Added by blupp over 15 years ago

My problem still exists. I also tried to RTFM, but this tipp is also not working for me.

Passing / Matching the Query string (GET variables)¶

If you wanna pass the Query String (?foo=bar) to the rewrite destination you have to explicitly match it:

url.rewrite-once = (
    "^/news/([^\?]+)(\?(.*))?" => "/news.php?title=$1&$3" 
)

If I understand it correct, so I have to write

"^/tag/([^\?]+)(\?(.*))?" => "/tag/$3" 

but nothing happens, the string is ignored and no rewrite is done.

What to do? Should I use a newer, maybe selfcompiled version?
Any hint is welcome!

RE: rewrite problem - Added by nitrox over 15 years ago

Try debug.log-request-handling = "enable"

RE: rewrite problem - Added by blupp over 15 years ago

debug.log-request-handling isn`t working in this version (1.4.19 Debian Lenny).
Anything else?

RE: rewrite problem - Added by blupp over 15 years ago

btw. rewrite is working!

the full line in /etc/lighttpd/conf-enabled/site is looking like this

url.rewrite-once = (
"^/tag/([^\?])(\?(.*))?" => "/tag/$3",
"^(.*)(textpattern|event)(.*)" => "$0",
"^(.*)about(.*)" => "$1impressum$2",
"^(.*)article(.*)" => "$1artikel$2",
)

only the "tag" rewrite line is ignored ...

RE: rewrite problem - Added by blupp over 15 years ago

It was my fault!
I forget to escape the "." in my host condition.

$HTTP["host"] =~ "^www\.url\.com$" {

Thanks these guys at the #lighttpd irc-channel!

    (1-5/5)