Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mod_rewrite passing variables

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

like image 623
Nathan H Avatar asked May 11 '26 14:05

Nathan H


1 Answers

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.

like image 119
davethegr8 Avatar answered May 14 '26 03:05

davethegr8



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!