Hi there,
I would like to have
eg.
www.domain.com/api/json/implode/abc/and/a/b/c...
equal to
www.domain.com/api/jason/?method=implode&key=abc¶m1=and¶m2=a¶m3=b¶m4=c...
cheers
James
Hi there,
I would like to have
eg.
www.domain.com/api/json/implode/abc/and/a/b/c...
equal to
www.domain.com/api/jason/?method=implode&key=abc¶m1=and¶m2=a¶m3=b¶m4=c...
cheers
James
You could do something like this:
RewriteRule ^/api/json/([/]*)/([/]*)$ /api/jason/method=$1&key=$2
RewriteRule ^/api/json/([/]*)/([/]*)/([/]*)$ /api/jason/method=$1&key=$2¶m1=$3
RewriteRule ^/api/json/([/]*)/([/]*)/([/]*)/([/]*)$ /api/jason/method=$1&key=$2¶m1=$3¶m2=$4
RewriteRule ^/api/json/([/]*)/([/]*)/([/]*)/([/]*)/([/]*)$ /api/jason/method=$1&key=$2¶m1=$3¶m2=$4¶m3=$5
RewriteRule ^/api/json/([/]*)/([/]*)/([/]*)/([/]*)/([/]*)/([/]*)$ /api/jason/method=$1&key=$2¶m1=$3¶m2=$4¶m3=$5¶m4=$6
# keep expanding this pattern out for however many paramas you need to be
# able to handle...
But cleaner would be something like this:
RewriteRule ^/api/json/([/]*)/([/]*)$ /api/jason/method=$1&key=$2
RewriteRule ^/api/json/([/]*)/([/]*)/(.*)$ /api/jason/method=$1&key=$2¶ms=$3
ie: stuff all trailing optional params into a single parameter.
I don't think it's possible to dynamically figure out the number of param
s, but you can do something close:
RewriteRule ^/api/json/([^/]+)/([^/]+)/(.*) /api/jason/?method=$1&key=$2¶ms=$3
This will extract method
and key
individually but put all the additional parameters into params
, which you can split later within your script.