Skip to content
PHP Logo

How can mod_rewrite in .htaccess be used to beautify URLs in PHP?

Mod_rewrite in .htaccess can be used to beautify URLs in PHP by rewriting URLs to a more user-friendly format. This can help improve the readability of URLs and make them more SEO-friendly. To achieve this, you can create rewrite rules in the .htaccess file that map the user-friendly URLs to the actual PHP script that handles the request. ```apache RewriteEngine On RewriteRule ^products/([0-9]+)/?$ product.php?id=$1 [NC,L] ```