How can mod_rewrite be used to rewrite URLs in PHP applications?
Mod_rewrite can be used to rewrite URLs in PHP applications by creating rewrite rules in the .htaccess file. This allows for cleaner and more user-friendly URLs, as well as improving SEO by making URLs more readable to search engines.
```php
RewriteEngine on
RewriteRule ^products/([0-9]+)/?$ product.php?id=$1 [NC,L]
```
In this example, the rewrite rule will redirect URLs like /products/123 to product.php?id=123. This can be customized to fit the specific needs of the application.
Keywords
Related Questions
- How can error reporting settings in PHP impact the ability to use the header() function for redirection?
- What are some best practices for handling duplicate entries in arrays and merging them into a new array in PHP?
- What are some alternative public CD databases, besides freedb.org, that can be accessed and utilized in PHP applications?