views:

20

answers:

1

I'm working on some rewrite rules, and for some reason a regexp I'm not expecting to pass (and does pass not on any of my regexp testers) is passing in mod_rewrite.

The URL in question is:

http://url.com/api/projects.json?division=aa

And the rewrite rule is:

RewriteEngine On
RewriteBase /
RewriteRule ^api\/([^.?#/%\s]+)\.([^#?\s]+)$ api.php?type=$1&format=$2 [NC,L] 

Because the second capture is immediately followed by $ I'd expect that URL to fail because of the query string, but it seems to accept just fine and pass the two parameters to GET.

Any thoughts?

+2  A: 

Note: Query String

The Pattern will not be matched against the query string. Instead, you must use a RewriteCond with the %{QUERY_STRING} variable.

Snip from the bottom of the docs

pycruft
Cheers--so I'd just want to add a rewrite condition like: RewriteCond %{QUERY_STRING} ^$Thanks pycruft.
JustinB