So - you want to improve your search engine rankings, and SEO experts are telling you that Google may be penalizing you for having links to your site using www in some cases and no www in others, as the spider may see it as duplicate content. And so they've recommend you create a 301 redirect to send all non-www links to www. You try it, and to your horror, the page now loops through so many redirect iterations that the site won't display at all. Or, you try the common syntax and it messes up all your subdomains.
Well, there's hope. Here's a 301 redirect syntax that does not loop, and does not affect your subdomains.
If you're new to 301 redirects, the first thing you want to do is create or edit an existing .htaccess file, which should be in your public_html or web root folder. Add the following lines, substituting your actual domain name instead of the 'yourdomain' and 'com' we list here (So, change out the green text)
This one will take you from non-www to www:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(.*)\.yourdomain\.com$ [NC]
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [R=301,L]
- 4 Пользователи нашли это полезным
Связанные статьи
Powered by WHMCompleteSolution