Mod_rewrite: check user request string in url?

I am trying to use URL rewriting in my new project. But I also need to be allowed to customize the user request in the URL.

I just want to know how to write a rewrite rule for this URL

http://www.mysite.com/edit/123/?q1=value1&q2=value2

to become that

http://www.mysite.com/index.php?action=edit&id=123&q1=value1&q2=value2

The custom query string must be allowed without restriction.

Millions of thanks ...

+3
source share
1 answer

Just make your rule like any other rule and add the QSA (Query String Append) modifier at the end.

RewriteEngine On
RewriteRule ^/([A-Za-z0-9]+)/([0-9]+)/$ index.php?action=$1&id=$2 [L,QSA]
+5
source

All Articles