views:

223

answers:

1

currently I have this setup in our simple-hosts.conf:


url.rewrite-once = (
    ".*.(js|ico|gif|jpg|png|css|php|htm)(?.*)?$" => "$0",
    "/slapi" => "/slapi/index.php"
)

Works great, except the above fails when I have a dot in the query string:

?url=http://google.com

My regexpy is not 1337

+3  A: 

Why not just use the server.error-handler-404 = "/path/to/index.php"?

But as for the regex itself, you have many unescaped characters in there. The second . I'm assuming you mean as a literal .. If so, you need to escape it with a backslash \.. The same goes with the ? character (which again, I'm assuming you mean a literal ?). So the regex should be:

".*\\.(js|ico|gif|jpg|png|css|php|htm)(\\?.*)?$"

Plus, you could improve it even more by removing the question mark around the query pattern (I prefer this syntax, I find it easier to read):

".*\\.(js|ico|gif|jpg|png|css|php|htm)(\\?.*|)$"
ircmaxell
Not working, but thanks. I will update in a bit, but we are tracing the calls, maybe an issue with the squid cache
mike clagg
It is not the caching layer. I called the light box directly, and even removed the line above and it works for everything until I add a dot in the request
mike clagg
What is it doing exactly? Forwarding the request to $0 (and hence a lighttpd 404 error)? Not rewriting it at all (when it should?)? Etc...?
ircmaxell
yes, I am getting a 404, and I have the error-handler-404 in the simple-vhost.conf
mike clagg
So the URL is getting rewritten then (when it's not supposed to be)? The EXACT url you're getting the 404 for is "?url=http://google.com"? What's the 404 line from the http log?
ircmaxell
127.0.0.1 dev.xxxxxx.com - [02/Jun/2010:16:01:09 -0500] "GET /slapi/alias/?url=http://google.com HTTP/1.0" 404 345 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.55 Safari/533.4
mike clagg
Two questions. First, are you 100% positive that the problem is in that rewrite (I can't see any possible reason that regex would match with a . in it)? Second, can you post the relevant configuration section?
ircmaxell
I agree. I am unaware of why it is choking. The regex seems fine.I will say that the code works great on Apache with the old mod_rewrite .htaccess, and works fine with a url in the request.Also, if I remove the above regex, and just keep the line: "/slapi" => "/slapi/index.php"the app works without the dot, but 404's withWhat conf do you want to see?
mike clagg
Ok, I just did some debugging on a local install of lighttpd, and here's what I came up with that appears to work... `"^[^?]*\.(js|ico|gif|jpg|png|css|php|htm)(\?.*|)$"`. Adding the starting `^` appears to have made it stop matching urls with a `.` in them (and I'm not sure why, a little bit of black magic I guess). The initial `.` changed to a `[^?]` so that it would not match urls in the form of `?url=http://www.google.com/test.htm`. Give that a shot...
ircmaxell
Thanks, that worked perfectly!! you are the man
mike clagg