SwissLucien
New Member
If you're using a blogging platform, you don't need to read this.
This is one of those technical things that people who are new at designing websites miss, but causes trouble when trying to rank a site.
Let's say I have a website called "domain.com".
On domain.com, I've decided to put my static content on http://www.domain.com
http://blog.domain.com/
Your web server is set up to take this information and use it to display the proper information. So, what these two links in the address bar display, respectively, are the following files on my server:
/home/public_html/domain/www/index.html (http://www.domain.com/)
/home/public_html/blog_on_domain/www/index.html (http://blog.domain.com/)
Let me quickly break down the addresses above. "http" is the protocol used to access the page. "www" and "blog" are subdomains. "domain.com" is the actual domain, and it is completely unrelated to "domain.net" or other variants.
What you should take from this is that "www" is actually a subdomain, exactly like "blog" in our example. The danger here is that Apache defaults to allowing the "www" subdomain to access the exact same site as the actual domain. In our example, Google can index BOTH "www.domain.com" and "domain.com", and it treats them as different websites.
Visually:
http://www.domain.com/ points to: /home/public_html/domain/www/index.html
http://domain.com/ points to: /home/public_html/domain/www/index.html
Suddenly, all of your content is duplicate content. You're stealing it from yourself.
Google makes an effort to counter-act this foolishness with the "canonical" meta tag and some options in Google Webmaster Tools, but both still leave much (SEO power) to be desired.
So, here's the quick-and-easy way to resolve the issue.
Hop on your FTP client and pull up your server. I'm assuming that you're using Apache on a Linux machine (and you probably are). Go to the web root for your website. This is where your index file is (index.html/.php/etc). Look for an .htaccess file. Sometimes it'll just look like a file with no name. If it doesn't exist, create it (it's just an extension with no actual file name, ".htaccess").
Make sure that the file has these two lines at the top:
Code: Options +FollowSymLinksRewriteEngine OnAnd then add the following lines, where domain.com is your domain:
Code: # Redirect non-www and IP addresses to www.# If this is a virtual host it also needs ServerAlias set up in httpd.conf (else it goes to the first VirtualHost and skips the .htaccess)RewriteCond %{HTTP_HOST} !^www.domain.com$ [NC]RewriteRule (.*) http://www.domain.com/$1 [R=301,L]Now, save the file to your site and check if domain.com properly redirects to www.domain.com. Sometimes the change can take a couple minutes to take effect. If this doesn't work as planned, you might be on a Virtual Host that hasn't been set up properly or mod_rewrite isn't enabled on your server. If that's the case, do the following:
Again, hop on your FTP client and go to the following directory:
/etc/httpd/conf
and open httdp.conf for editing.
Find this line:
Code: LoadModule rewrite_module modules/mod_rewrite.soAnd make sure it's not commented (there shouldn't be a # in front of it).
Next, see if a virtual host is already set up. If there is, it should look something like this:
Code: <VirtualHost *:80>DocumentRoot /home/public_html/domain/www/ServerName www.domain.comServerAlias domain.com</VirtualHost>There could be a bunch of arguments in there. If there are, great, leave them. But make sure that you have both "ServerName" and "ServerAlias" set in the way I have them set above, of course using your domain instead of my generic domain.com.
If there is no VirtualHost set up already and the original changes to your .htaccess file didn't work, revert everything and hire a professional to look into it. Redirects can really destroy your site if done improperly.
The best way to learn how to do this is to set up a web environment on your computer and mess around with .htaccess and httpd.conf settings without destroying a website in a production environment. But if your site comes up as www and non-www, you're pointlessly losing some serious ranking potential.
PS: If this seems really complicated, you need to understand that it's a very small part of the big picture in good on-page SEO practices. Please please consult an expert instead of throwing your money and time away on services that you're not even sure will work. Send me a PM if you have any questions about htaccess files or affordable SEO consultations in general.
This is one of those technical things that people who are new at designing websites miss, but causes trouble when trying to rank a site.
Let's say I have a website called "domain.com".
On domain.com, I've decided to put my static content on http://www.domain.com
http://blog.domain.com/
Your web server is set up to take this information and use it to display the proper information. So, what these two links in the address bar display, respectively, are the following files on my server:
/home/public_html/domain/www/index.html (http://www.domain.com/)
/home/public_html/blog_on_domain/www/index.html (http://blog.domain.com/)
Let me quickly break down the addresses above. "http" is the protocol used to access the page. "www" and "blog" are subdomains. "domain.com" is the actual domain, and it is completely unrelated to "domain.net" or other variants.
What you should take from this is that "www" is actually a subdomain, exactly like "blog" in our example. The danger here is that Apache defaults to allowing the "www" subdomain to access the exact same site as the actual domain. In our example, Google can index BOTH "www.domain.com" and "domain.com", and it treats them as different websites.
Visually:
http://www.domain.com/ points to: /home/public_html/domain/www/index.html
http://domain.com/ points to: /home/public_html/domain/www/index.html
Suddenly, all of your content is duplicate content. You're stealing it from yourself.
Google makes an effort to counter-act this foolishness with the "canonical" meta tag and some options in Google Webmaster Tools, but both still leave much (SEO power) to be desired.
So, here's the quick-and-easy way to resolve the issue.
Hop on your FTP client and pull up your server. I'm assuming that you're using Apache on a Linux machine (and you probably are). Go to the web root for your website. This is where your index file is (index.html/.php/etc). Look for an .htaccess file. Sometimes it'll just look like a file with no name. If it doesn't exist, create it (it's just an extension with no actual file name, ".htaccess").
Make sure that the file has these two lines at the top:
Code: Options +FollowSymLinksRewriteEngine OnAnd then add the following lines, where domain.com is your domain:
Code: # Redirect non-www and IP addresses to www.# If this is a virtual host it also needs ServerAlias set up in httpd.conf (else it goes to the first VirtualHost and skips the .htaccess)RewriteCond %{HTTP_HOST} !^www.domain.com$ [NC]RewriteRule (.*) http://www.domain.com/$1 [R=301,L]Now, save the file to your site and check if domain.com properly redirects to www.domain.com. Sometimes the change can take a couple minutes to take effect. If this doesn't work as planned, you might be on a Virtual Host that hasn't been set up properly or mod_rewrite isn't enabled on your server. If that's the case, do the following:
Again, hop on your FTP client and go to the following directory:
/etc/httpd/conf
and open httdp.conf for editing.
Find this line:
Code: LoadModule rewrite_module modules/mod_rewrite.soAnd make sure it's not commented (there shouldn't be a # in front of it).
Next, see if a virtual host is already set up. If there is, it should look something like this:
Code: <VirtualHost *:80>DocumentRoot /home/public_html/domain/www/ServerName www.domain.comServerAlias domain.com</VirtualHost>There could be a bunch of arguments in there. If there are, great, leave them. But make sure that you have both "ServerName" and "ServerAlias" set in the way I have them set above, of course using your domain instead of my generic domain.com.
If there is no VirtualHost set up already and the original changes to your .htaccess file didn't work, revert everything and hire a professional to look into it. Redirects can really destroy your site if done improperly.
The best way to learn how to do this is to set up a web environment on your computer and mess around with .htaccess and httpd.conf settings without destroying a website in a production environment. But if your site comes up as www and non-www, you're pointlessly losing some serious ranking potential.
PS: If this seems really complicated, you need to understand that it's a very small part of the big picture in good on-page SEO practices. Please please consult an expert instead of throwing your money and time away on services that you're not even sure will work. Send me a PM if you have any questions about htaccess files or affordable SEO consultations in general.