Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using Lighttpd to serve a GET based API that I'm working on, and I'm having some difficulty with re-writing requests.

My API calls are very simple. An example would be :


This is what I have:

url.rewrite-once = ( "^/methodfoo(.*)" => "/index.php$1&method=methodfoo")

This works fine if all methods were shallow, but I have methodfoo/submethod to deal with. What I'd like to do is use a rule that can split this up for me, appending a &submethod to the end of the rewritten string.

For instance:


Would be re-written to:


Can I do that without an explicit rule for each submethod?

Additional Information:

Yes, I know I can use a rule like:

 "^/methodfoo/(.*)/(.*)" => "/index.php$2&method=methodfoo&submethod=$1"

However, That fuglifies (TM) my link structure, as it would have to match:


When I really want:


Thanks in advance for any suggestions.

share|improve this question
up vote 1 down vote accepted

Solved with this:

url.rewrite-once = ("^/foo/(.*)([/?])(.*)" => "/index.php$2&$3&m=foo&sub=$1")

This allows links like:




Not sure if that's the best way to do it, but it does let me skip writing a rule for each sub method.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.