What role does the .htaccess file play in addressing duplicate content issues in PHP websites?
Duplicate content issues in PHP websites can arise when the same content is accessible through multiple URLs. This can negatively impact SEO rankings and confuse search engines on which version of the content to index. One way to address this issue is by using the .htaccess file to set up 301 redirects from duplicate URLs to the preferred canonical URL.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.example.com [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
Related Questions
- What are the potential pitfalls of using variables in PHP, especially when dealing with object properties?
- What role do PHP functions like mysql_error(), addslashes(), and htmlspecialchars() play in ensuring data integrity when inserting into a database?
- What are the advantages and disadvantages of using PHP_SELF in form actions?