home

Quickies, by Andrea Olivato

text

Htaccess rewrite : forward query string and add params

This shows a simple solution to make some redirs adding parameters to querystring. I used this to implement an API service.

Options +FollowSymlinks
RewriteEngine on
 
RewriteCond %{REQUEST_URI} !/index.php* [NC]
RewriteCond %{QUERY_STRING} ^(.+)$ 
RewriteRule ^([^.]+).([^?]+)$ index.php?method=$1&format=$2&%1

Example request:

/create.json?param=something&foo=smelse

Redirects to

/index.php?method=create&format=json&param=something&foo=smelse

2 years ago

July 29, 2009
Comments (View)
blog comments powered by Disqus