Mobile app version of vmapp.org
Login or Join
Rivera981

: Re-writing URL's with lighttpd 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

@Rivera981

Posted in: #Lighttpd #UrlRewriting

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 :

url:/method/submethod?var1=something&var2=something&key=something


This is what I have:

url.rewrite-once = ( "^/methodfoo(.*)" => "/index.php&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:

url://methodfoo/submethod?foo=bar&foobar=foo


Would be re-written to:

url://index.php?foo=bar&foobar=foo&method=methodfoo&submethod=foo


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&method=methodfoo&submethod="


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

url://methodfoo/submethod/?foo=bar&foobar=foo


When I really want:

url://methodfoo/submethod?foo=bar&foobar=foo


Thanks in advance for any suggestions.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Rivera981

1 Comments

Sorted by latest first Latest Oldest Best

 

@Rivera981

Solved with this:

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


This allows links like:

/foo/bar?foo=bar


Or

/foo/bar/foobar/foo?bar=foo


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

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme