From 385385f27fb217f3e3045908d538d84969219cbb Mon Sep 17 00:00:00 2001
From: RastaPopoulos <rastapopoulos@spip.org>
Date: Tue, 15 Nov 2011 07:59:37 +0000
Subject: [PATCH] =?UTF-8?q?Allez=20on=20teste=20une=20petite=20nouveaut?=
 =?UTF-8?q?=C3=A9.=20En=20attendant=20un=20jour=20une=20vraie=20gestion=20?=
 =?UTF-8?q?du=20routage=20des=20URLs,=20on=20va=20prendre=20rapidement=20e?=
 =?UTF-8?q?n=20compte=20des=20URLs=20propres=20pour=20les=20APIs.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Le htaccess sait donc gérer :
http://site/api/truc => action=truc
http://site/api/truc/bidule/32 => action=truc&arg=bidule/32

Le premier bloc après le slash correspond au nom d'une action, et tout ce qui suit sera "arg". Évidemment ça garde la query string qu'il y aurait en plus.

On peut donc écrire :
http://site/api/xmlrpc
http://site/api/atom/patates/1234
---
 htaccess.txt | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/htaccess.txt b/htaccess.txt
index c300fd0c30..627cdc8581 100644
--- a/htaccess.txt
+++ b/htaccess.txt
@@ -90,6 +90,13 @@ RewriteRule ^([1-9][0-9]*)$     spip.php?action=redirect&type=article&status=301
 #
 ###
 
+###
+# APIs http://site/api/xmlrpc
+
+RewriteRule ^api/([\w]+)(/(.*))?$ spip.php?action=$1&arg=$3 [QSA,L]
+
+# Fin des APIs
+###
 
 ###
 # URLs "propres", "propres2", "libres", "arbo"
-- 
GitLab