How can mod_rewrite be used to make URLs look more aesthetically pleasing in PHP?
Mod_rewrite can be used to rewrite URLs in a more user-friendly and aesthetically pleasing way by converting dynamic URLs into static-looking URLs. This can improve the readability of URLs for users and make them more search engine friendly. By using mod_rewrite, you can create clean URLs that are easier to remember and understand.
```php
RewriteEngine On
RewriteRule ^products/([0-9]+)/?$ product.php?id=$1 [NC,L]
```
This code snippet uses mod_rewrite to rewrite a URL like "example.com/product.php?id=123" to "example.com/products/123/", making the URL more aesthetically pleasing and user-friendly.
Keywords
Related Questions
- How can the PHP function usort() be utilized to sort strings with numbers in PHP arrays effectively?
- Is using a for loop a more efficient way to handle displaying multiple text fields in PHP compared to using if statements?
- Are there any best practices or specific techniques to handle cross-server communication and script execution in PHP?