How can PHP developers ensure that dynamic URLs are properly redirected to canonical URLs using .htaccess files?
PHP developers can ensure that dynamic URLs are properly redirected to canonical URLs using .htaccess files by implementing 301 redirects. This can be achieved by using mod_rewrite rules in the .htaccess file to redirect any dynamic URLs to their corresponding canonical URLs. This ensures that search engines and users are always directed to the correct URL for a given page, improving SEO and user experience. ```apache RewriteEngine On RewriteCond %{QUERY_STRING} ^id=123$ RewriteRule ^page\.php$ /canonical-page? [L,R=301] ```