1

I've had a search through and seen problems similar to mine, but do not match completely.

I'm running nginx with PHP for an API on a site I'm creating and I have urls such as this:

http://api.example.com/?uid=10&api=23425292134&profile

Which returns data in JSON. I'd like to know using rewrite rules how to change it to;

http://api.example.com/uid/10/api/23425292134/profile

Occasionally, but not always, the profile $_GET will have a value like this:

http://api.example.com/?uid=10&api=23425292134&profile=1

So I'd like it to be able to work with changes like that, so it resolves to:

http://api.example.com/uid/10/api/23425292134/profile/1

I have searched for quite a while, and cannot find the answer that I'm looking for to this, please also bear in mind, that some URL's will have more/less GET requests so I'm unsure if this is possible or not.

Thank you in advance!

Alex White
  • 11
  • 1
  • 1
    That's not exactly difficult. [Rewriting an arbitrary number of path segments to query parameters](http://stackoverflow.com/q/3655893) explains the generic approach. – mario Aug 21 '14 at 12:44
  • But it's much simpler to do it in PHP – Alexey Ten Aug 21 '14 at 12:49
  • Could you explain more about doing it in PHP? And I will look at the link mario, thank you! Edit: Mario, what happens when profile does not equal to a number? That would not work – Alex White Aug 21 '14 at 12:54

0 Answers0