What are common ways to achieve SEO-friendly URLs in PHP websites?

SEO-friendly URLs in PHP websites can be achieved by using descriptive keywords in the URL structure, keeping URLs short and readable, using hyphens to separate words, and avoiding special characters or symbols. One common way to achieve this is by using URL rewriting techniques, such as mod_rewrite in Apache, to rewrite dynamic URLs into static, keyword-rich URLs.

// Enable mod_rewrite in .htaccess file
RewriteEngine On

// Rewrite rule to convert dynamic URLs to SEO-friendly URLs
RewriteRule ^products/([0-9]+)/([a-zA-Z0-9_-]+)$ product.php?id=$1&name=$2 [NC,L]