<img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=1657797781133784&amp;ev=PageView&amp;noscript=1">

Where Marketers Go to Grow

Please select one of the blog options to subscribe.

October 31, 2013

How to Help Avoid SEO Pitfalls with 301 Redirects

Written by | @

148465706It’s midnight. You’ve just spent the last 3 days putting your latest and greatest site together, combining the design of all the latest web trends with the incredible insightful and useful content you have accumulated over the last few years.

Everything is in place, except one last task; domain names. You purchase an array of domain extensions for you application name, .com, .net, .info, all the gang from your favorite domain registrar. Finally, you configure your domains so each domain’s DNS is pointing at your web hosting.

Satisfied, you sit back to contemplate the success of your deployment, and think to yourself “everything is now complete”.

Unfortunately, that little blissful bubble is going to burst soon. Your site starts to rank in Google semi-successfully but as soon as things look like they’re going in the right direction, your site’s ranking in Google and indeed it’s overall page ranking starts to drop, and so does your traffic.

You’re confused, distraught and desperately seeking answers. “Is it my site’s design?” you ponder, “the content? maybe the stock photos? am I even using social media correctly?”.

These questions haunt you for hours as you spend another night face planted millimeters away from your computer screen, searching for the one true answer to all your problems. What could it be?

One Solution, One Answer

We’ve all done this at some point. I’ve done this at some point. It’s horrible. Furthermore, the solution to everything is so simple, it knocks you for six when you realise it for the first time and you check for it each time afterwards. The problem lies with that last little task we always assign ourselves right at the end of the project, right when we are at our most tired and most vulnerable; the domains.

Google likes original content, in fact it loves it more than a dog loves eating peanut butter. (Seriously, go search for it on youtube, it’s crazy!). However, the key word here is “original”, Google hates when it discovers content, which is exactly the same across multiple domains. In fact it hates duplicate content more than cats hate baths (again search on youtube and yes, I have a thing for animal videos!). In fact, Google will even penalize single domains that have repetitive content throughout the site, so it’s even more vital that your content is relative and original to your desired cause.

So how does that help our previously spoken scenario?

“Finally, you configure your domains so each domain’s DNS is pointing at your web hosting."

By performing that simple task, we have configured our domains in such a way that when Google starts to crawl through our domains it will see each domain as a separate website. In addition, because each domain is pointing to the same website, Google will think that these websites are all showing content that’s the exact same in an attempt to hijack their way into search results.

As a result, to weed out unnatural search results, Google will penalise each domain and their position in search results, as well as in their individual page ranking, will deteriorate. Only one domain should be assigned to a single website in order to inform the Google bots and program algorithm that this content is original and belongs to our website, thus removing the penalties.

Many players, one goal

Hang on a minute! What we are trying to achieve with the multiple domains is done the same way by many others, how come they have not had to suffer the penalties? In addition, why are multiple domains frowned upon by Google? Our intentions made complete sense, so why is Google restricting us?

All great questions, young padawan. Yes, many other companies and websites have successfully connected multiple domains to a single website, and yes this method does make complete sense. However, Google does allow this to happen. You see the issue was not what in what we had done, but how we did it. Instead of assigning the DNS of each domain to the nameserver of our web hosting, we should’ve set this for our main .com domain, and then used something called server-side “301 redirects” for our other domains.

Server-side 301 redirects are redirection rules used by web servers to tell bots and servers that a domain name’s location has been moved elsewhere and then tells the bots and servers where to go find the site. Where the 301 redirect comes into play with our scenario is that using a 301 redirect means Google is informed that we have one website but the content can be found through multiple domain names, meaning we won’t receive any penalties from Google.

In addition, our server will be able to handle traffic seamlessly through these multiple domains more effectively than if we had each domain configured to the website, improving our website’s overall loading speed.

If you’re still scratching your head a little bit about 301 redirects, I highly suggest checking out Google Webmaster Tools’ video tutorial on 301 redirects which looks like it came straight out of the 90’s. There is also an accompying web page that goes with the information dicussed in the youtube video.

To see a working example of a 301 redirect, visit http://www.leanlabs.info.

What happens next is this: a 301 redirect comes into play that tells your browser to redirect to http://www.lean-labs.com which is the main website URL for Lean Labs.

How simple and cool is that?

Apply Directly to Affected Area

So how do we go about implementing a 301 redirect? It’s actually really simple as long as you have access to your web hosting server through FTP or through SSH in a command prompt application or program and running Apache on your server. Let’s assume your website’s folder on it’s web hosting server looks like the following:

leanlabs1

If you are running apache, all you have to do it create a new file called “.htaccess” (NOTE: remember the “.” at the beginning, as this file is a system file and the period tells the Apache system this is a system file and not a file to render in the browser).

So our folder should now look like:

leanlabs2

All we need to do now is edit the .htaccess file and add our 301 redirect code which looks sort of like the following code:

RewriteEngine on
RewriteCond %{HTTP_HOST}
RewriteCond %{HTTP_HOST} !^domain2\.com
RewriteRule (.*) http://www.domain1.com/$1 [R=301,L]

NOTE: Please ensure that you have the Mod Rewrite module enabled for Apache. For those with root access to their server, you can follow this guide for ubuntu specifcally, but it can be used as a basis for most Linux servers: http://askubuntu.com/a/48363. If you do not have root access, or on shared hosting, please contact your hosting provider.

In the example code above, we have enabled the RewriteEngine in apache, we collect the domain name our visitor has used to access our web hosting server, then on the 3rd line, we check to see if the domain matches “www.mywebsite.com”. If it doesn’t, we redirect the user to “www.mywebsitedomain.com” using a 301 redirect, which indicates to all bots and servers that this redirect is permanent. Feel free to copy and paste the above code into your .htaccess file, but make sure you change the domain name to match your website’s main domain name.

If you are running Nginx instead of Apache, you will need to have root access to the server and will need to configure the server block for the website you want to initiate the 301 redirect on:

 Screen_Shot_2013-10-31_at_1.18.01_PM

Please see online documentation for creating and integrating 301 redirects with any other web hosting platforms.

NOTE: It’s worth pointing out that you will need to add another rewrite rule for both Apache and Nginx to redirect www.mywebsitedomain to mywebsitedomain. So for example in Apache:

RewriteEngine on
RewriteCond %{HTTP_HOST}
RewriteCond %{HTTP_HOST} !^www\.domain2\.com
RewriteRule (.*) http://www.domain1.com/$1 [R=301,L]

and Nginx:

server_name www.domain2.com;
return 301 http://www.domain1.com$request_uri;

Forward Thinking

The best attitude to have with 301 redirects is to think about them as if you are moving your home. You’re going to want to set up a forwarding address to make sure all that lovely junk mail lands on your new doorstep.

However, in a more serious tone, for your website it’s extremely important to ensure that Google is aware that your multiple domains are set up and are being forwarded through 301 redirects to your main website’s domain. 301 redirects are a sign of a permanent move and so Google won’t be surprised when it returns to crawl your site later on and your domains are still pointing at the same site.

If you value all your hard SEO work, it’s imperative to ensure your 301 redirects are set up and working flawlessly. If they are, you’ll be like a dog eating peanut butter, rather than a cat being forced to have a bath.

Callum Hopkins is full stack developer at Lean Labs, an Inbound Marketing agency with a passion for responsive web design. Callum lives in Northeast Scotland, which suits Lean Labs well as it spans 4 states and 3 countries.  For more articles by Callum visit our Inbound Marketing blog.

lean-labs-cta

Topics: Inbound Marketing SEO

Subscribe to HubSpot's Marketing Blog

Join 300,000+ fellow marketers! Get HubSpot's latest marketing articles straight to your inbox. Enter your email address below:

3 Comments

Sorry we missed you! We close comments for older posts, but we still want to hear from you. Tweet us @HubSpot to continue the discussion.

3 Comments