I'm writing an API where a URL needs to be passed via $_GET variables. Now that's al开发者_开发百科l cool when I'm just using the raw URL, create_page.php?url=http://example.com
, but I've tried to make this look pretty using htdocs like I have the other API calls and it doesn't work. Here's my htaccess code so far.
RewriteRule ^create_page/(.*)$ create_page.php?url=$1 [L]
So basically I want the official API call to look like http://api.example.com/create_page/http://google.com/
but the http:// and the ending / of the url variable make this not work. Is there a workaround in the htaccess rewrite to somehow still accomplish what I'm trying to do?
That is not a valid URL. You'll need to enforce in the API that you are only passed encoded URLs.
The API call will need to be http://api.example.com/create_page/http%3A%2F%2Fgoogle.com instead, which will then work fine.
精彩评论