Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Dunmail

macrumors regular
Original poster
Mar 27, 2009
224
4
Skipton, UK
I'm having one of those "brain's gone for a walk" days :eek:

I'm looking at implementing a RESTful web service in which all requests are handled by a script or scripts at the root of the service, lets say this script is at: "mydomain/api/handler.php".

Now according to the principles of REST each part of the API has its own URL such as "mydomain/api/date/" which should be handled by the script.

Having searched the interweb I came across http://blog.teamlazerbeez.com/2010/05/25/serving-restful-urls-with-mod_rewrite/ which had the rule:

Code:
RewriteRule ^/api.*$ /api/handler.php [L]

However it didn't work. RewriteRule is enabled and working in my .htaccess file. What am I doing wrong?
 

angelwatt

Moderator emeritus
Aug 16, 2005
7,852
9
USA
Rewrite has to be turned on first:
Code:
RewriteEngine On
Also try,
Code:
RewriteRule ^api /api/handler.php [L]
Though part of me wonders if that's circular since you're rewriting to a path that matches the rule still.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.