Clean URLs with parameters
Why would you want clean URLs that also allows parameters? Well for me the answer was to create an API.
RewriteEngine on
RewriteBase /api/
RewriteCond $1 !^(index\.php)
RewriteRule ^(.*)$ index.php/?route=$1&%{QUERY_STRING} [L]
This will route anything to the route variable but also send the original query string.
http://example.com/api/users?user_id=365
Will give you a $route of '/users' and a $_GET['user_id'] of '365'. (Or however you gather your vars in your language)
Written by Gerben Jacobs
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#