How can I rewrite this url api.domain.com/v1/json/account?id=123 to api.domain.com?id=123&v=v1&f=json&t=account
RewriteCond %{HTTP_HOST} ^(api)\.[^\.]+\.[^\.]+$ [NC]
RewriteCond %{REQUEST_URI} ^/([^/]+)/([^/]+)/([^/]+)/?(\?%{QUERY_STRING})?$ [NC]
RewriteRule ^(.*)$ /?%{QUERY_STRING}&v=%1&f=%2&t=%3 [L]
v1always bev1,jsonalways bejson) or you need a bit more generic rule (wherejsonmay becomexml); 3) WhyQSAflag is not good (are you afraid that user may provide his own&v=value etc? 4) Where this rule will be placed -- in .htaccess or in config file (e.g.<VirtualHost>section)? 5) You want rewrite, not redirect? – LazyOne Jun 30 '11 at 15:33