How to turn a query string into a path
- Paste the address your script uses, with the parameters filled in.
product.php?id=12&cat=4becomes/product/12/4unless you type your own pattern. - A value that is all digits becomes a
[0-9]+pattern. Anything else becomes "one path segment". The sample values are only an example of the shape. - Copy the Apache block into the site root
.htaccess, or the nginx block into the server config. Then request the old URL and the new one.
Test the rules before you leave them on
The 301 only matches the parameter names in the order you entered, and it drops the query string so the pretty URL stays clean. Extra parameters, or the same parameters in another order, will not match that redirect. The internal rewrite still runs the script and keeps any extra query string it is given.
After you publish the file, follow the old URL with the redirect checker and confirm the status and the Location header with the HTTP header checker. If the same page answers on two addresses, set a canonical with the meta tag analyzer as a backstop.
Rules run in the browser. Nothing you type is sent to a server.