views:

83

answers:

3

I have the following mod_rewrite rule:

RewriteRule ^([^/.]+)/?$ search.php?action=procedure&procedureName=$1

This works fine in redirecting things like /blabla to /search.php?action=procedure&procedureName=blabla

The problem is that sometimes I want to pass a 'start' value (for pagination). For example, /blabla/?start=20.

Currently, it just ignores it. Printing out the $_REQUEST array doesn't show 'start'. I tried modifying the rule to:

RewriteRule ^([^/.]+)/\?start=([0-9]+)$ search.php?action=procedure&procedureName=$1&start=$2
RewriteRule ^([^/.]+)/?$ search.php?action=procedure&procedureName=$1

But it didn't do anything.

Any idea?

Thanks

+1  A: 

RewriteRule applies to the path. You need to use RewriteCond to match the query string.

http://httpd.apache.org/docs/2.2/mod/mod%5Frewrite.html#rewriterule

Or to just pass the query string through, use %{QUERY_STRING}

RewriteRule ^([^/.]+)/?$ search.php?action=procedure&procedureName=$1&%{QUERY_STRING}
jabley
+1  A: 

Actually I think I found my answer:

RewriteRule ^([^/.]+)/?$ search.php?action=procedure&procedureName=$1 [QSA]

The QSA allows it to pass query strings. Right?

nute
+3  A: 
RewriteRule ^([^/.]+)/?$ search.php?action=procedure&procedureName=$1 [L,NC,QSA]

The QSA means query string append, and it'll append $_GET vars you pass. Otherwise, they are normally not added.

davethegr8