How can mod_rewrite rules be structured to handle multiple parameters in PHP?
When using mod_rewrite in PHP to handle multiple parameters, you can structure the rules to capture each parameter separately using regular expressions and rewrite them into a query string format. This allows you to access the parameters in your PHP script using the $_GET superglobal array.
```php
RewriteEngine On
RewriteRule ^product/([^/]+)/([^/]+)$ index.php?product=$1&category=$2 [L]
```
In this example, the rule captures two parameters (product and category) from the URL and rewrites them into a query string format that can be accessed in PHP as $_GET['product'] and $_GET['category'].
Keywords
Related Questions
- How can the problem of unable to load dynamic library php_mysql.dll be resolved in PHP 5 installation on Windows?
- How can the use of arrays improve the handling of errors in PHP form validation, as demonstrated in the forum thread?
- How can PHP be used to efficiently handle form submissions that involve database interactions?