2013-11-01 73 views
0

我有一個網址如何使用htaccess的收集JSONP回調值

API /事/ JSON?回調= ABC,我想它重定向到

dothis.php?strEndPoint =東西&回調= ABC &格式= JSON

基部htaccess的我嘗試是:?

重寫規則^ API /(。)/(JSON)回調=(。)client.php strEndPoint = $ 1 &回調= $ 3 &格式=($ 2)

似乎並沒有工作:對

回答

0

測試使用

*

RewriteEngine On 
RewriteCond %{QUERY_STRING} callback\=(.*) 
RewriteRule /api/(.*)/(json) /client.php?strEndPoint=$1&callback=%1&format=$2 [R=301] 

您可以刪除R = 301只是爲了測試。

$ curl localhost/api/1111/json?callback=2222 -I 
HTTP/1.1 301 Moved Permanently 
Date: Fri, 01 Nov 2013 03:16:25 GMT 
Server: Apache/2.2.24 (Unix) DAV/2 mod_ssl/2.2.24 OpenSSL/0.9.8y 
Location: http://localhost/client.php?strEndPoint=1111&callback=2222&format=json 
+0

我在這裏測試過,它似乎沒有工作... http:// h taccess.madewithlove.be/ –