Mod_rewrite passing variables

I have the following mod_rewrite rule:

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

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

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

Currently, he is simply ignoring this. The listing of the $ _REQUEST array does not show "start". I tried to change the rule as follows:

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

But it did nothing.

Any idea?

thanks

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

QSAmeans the query string is being added and it will add the $ _GET vars that you pass. Otherwise, they are usually not added.

+11

RewriteRule . RewriteCond .

http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewriterule

, % {QUERY_STRING}

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

In fact, I think I found my answer:

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

QSA allows you to pass query strings. Correctly?

+1
source

Source: https://habr.com/ru/post/1720623/


All Articles