What are the best practices for maintaining SEO-friendly URLs while utilizing subdomains in PHP?

When using subdomains in PHP, it is important to maintain SEO-friendly URLs by ensuring that the subdomains are relevant to the content and that the URLs are structured in a clear and descriptive manner. One way to achieve this is by using mod_rewrite rules in your .htaccess file to rewrite subdomain URLs to a more user-friendly format.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^subdomain\.yourdomain\.com$
RewriteRule ^(.*)$ http://www.yourdomain.com/subdomain/$1 [L]