How can mod_rewrite be used to create search engine-friendly URLs in PHP?
Mod_rewrite can be used in PHP to create search engine-friendly URLs by rewriting URLs in a more user and search engine-friendly format. This can help improve the overall SEO of a website by making URLs more descriptive and easier to read for both users and search engines.
```php
RewriteEngine On
RewriteRule ^products/([0-9]+)/?$ products.php?id=$1 [NC,L]
```
In this example, the mod_rewrite rule is rewriting a URL like `example.com/products/123` to `example.com/products.php?id=123`, making the URL more user-friendly and potentially improving SEO.
Related Questions
- How can a logo be centered in PHP when displayed on a webpage?
- What are the potential issues with not properly handling the return value of mysql_query in PHP?
- What are the recommended alternatives to the mysql_* functions in PHP for database operations, and why are they preferred over the deprecated functions?