Can a simple URL redirect really lower your search engine rankings?

Posted in Jude LaCour, SEO by admin on the March 27th, 2008

Can a simple URL redirect really lower your search engine rankings?

Yes, it can. In fact, your competitors can easily use this Achilles’ heel to overtake you. However, you can safeguard your website now!

Merging, renaming, and especially moving web pages and subsequently, web addresses are commonplace. While the methods of redirecting URLs are many, there is only a single right way to make it search engine friendly. By following the detailed instructions in this tutorial, you will be doing it the right way using the most efficient and effective Search Engine Friendly method, 301 Redirects.

Upon completing this tutorial, you will learn the ins and outs of how this method works and therefore, why you should be doing it. While this tutorial is highly technical, it is nonetheless too indispensible to your website’s success to ignore.

Canonical Domains & the Problem with Duplicate Content

Canonical domains, also called subdomains, allow you to have other domains based off your primary domain. They are part of the domain name system (DNS). An example is info.yourwebsite.com where ‘info” is a subdomain of the domain ‘yourwebsite.com’. Here, the DNS entry for the domain yourwebsite.com points to a specific IP address on a server.

Canonical domains serve as aliases to domain names. Again, info.yourwebsite.com points to the same IP address as yourwebsite.com since it does share the same host server (where you upload your website files). Other possible canonical domains of yourwebsite.com are email.yourwebsite.com, store.yourwebsite.com, and of course, www.yourwebsite.com.

These subdomains can also be used as individual websites. Yahoo, for example, uses subdomains for their different services like mail.yahoo.com, messenger.yahoo.com, and more. These subdomains forward to another location.

So what is the dilemma? Well, to both the DNS system and us, http://www.yourwebsite.com and http://yourwebsite.com bring up the same web site since they are the same. Unfortunately, to search engines, they aren’t the same since subdomains are entirely different websites but with duplicate content. Therefore, they will be ranked lower since search engines penalize for duplicate content.

Beware Your Competitors & 301 Sabotage

Your competitors for search engine ranking can easily exploit the problem above. They can find further instances on your website that use www and non-www links. They can link these problem spots, again unintentional duplicate content, to further reduce your rankings. This is known as 301 Sabotage.

How to Protect Your Website & Ranking

The first step in protecting your website and ranking is to see if your website needs protection at all.

Step 1: Enter your website URL http://www.yourwebsite.com (replace ‘yourwebsite.com’ with your own domain).

Step 2: Watch the address bar to see if your destination is www.yourwebsite.com or yourwebsite.com. Keep the answer in mind.

Step 3: Now enter http://yourwebsite.com and see where you land.

After checking both http://www.yourwebsite.com and http://yourwebsite.com, did you land at the same URL (in this case either www.yourwebsite.com or yourwebsite.com)? If in both scenarios, you land at the same URL, you have no problems. As long as you land at the same place, it really does not matter how you got there.

For example, as long as www.google.com and google.com land on the google.com (without www), everything is fine.

However, if you land on different pages but with the same content, your website is open (whether intentionally or not) to exploitation via 301 Sabotage. Don’t worry, all you need to do is implement a 301 Redirect to protect your website and ranking.

How to Do 301 Redirection

The single correct method of redirecting your domain name to protect against 301 Sabotage and lowered search engine ranking is HTTP 301 (redirection header) or 301 Redirection.

HTTP Protocol is basically a set of headers that makes the Internet work. HTTP headers are seamless. Therefore, they are usually invisible to your website visitors. Yet they are a vital part of web server to web browser (IE, Netscape, FireFox, Safari, etc.) communication. Since they are exchanged before any web content, such as an HTML page, is sent to the browser, they are called headers. Basically, they appear at the head of the document.

Part of the standard HTTP headers control redirection. These are known as 3xx Headers since they are numbered from 300 and on (300, 301, 302, 303, and so on). In particular, the HTTP 301 header designates that a web page has been moved permanently. Another header usually immediately follows and communicates a new location that the web page has moved to.

Everyone (and everything) from website visitors to search engines now know that a web page or domain name is no longer in use. It also knows what the new location to be used is. Search engines, specifically, will automatically index the page as the same page. In our example, http://www.yourwebsite.com and http://yourwebsite.com are seen by the search engine as the same page and not duplicate pages.

While there are many techniques to do a 301 Redirection, some are best suited for forwarding entire websites and others for individual pages. The following section will show you three ways for 301 Redirection. These include:

§ How to use the PHP header() function for web server’s that support PHP

§ How to use the mod_rewrite function for Apache web servers

§ How to use the built-in forwarding that your web host might provide

Before testing any of the 301 Redirection methods above, you should first clear your web browser’s cache. This will allow you to see if it works or not. FireFox web browsers especially need to have the cache cleared or you will get an error message saying the URL Redirection limit has been reached.

Implementing 301 Redirection with PHP

You can use the PHP header function (http://www.php.net/manual/en/function.header.php) to do a 301 Redirection.

Use the code below to forward www.yourwebsite.com to yourwebsite.com.

<?php

if(stristr($_SERVER[”HTTP_HOST”], ‘www’)){

header(”HTTP/1.1 301 Moved Permanently”);

header(”Location: http://yourwebsite.com/” . $_SERVER[”REQUEST_URI”]);

exit();

}

?>

On the other hand, you can use the code below to forward yourwebsite.com to www.yourwebsite.com.

<?php

if(!stristr($_SERVER[”HTTP_HOST”], ‘www’)){

header(”HTTP/1.1 301 Moved Permanently”);

header(”Location: http://www.yourwebsite.com/” . $_SERVER[”REQUEST_URI”]);

exit();

}

?>

Don’t forget to use your own domain name in place of yourwebsite.com.

You should also note the following:

§ The HTTP 301 header is sent first then immediately followed by the new location.

§ The REQUEST_URI value is also forwarded since it is the path from the website to the web page. An example would be http://yourwebsite.com/phpcounter/index.php where the /phpcounter/index.php is the REQUEST_URI. Therefore, the forwarding code sends the web user to the page they requested.

§ The exit() statement ensures that the PHP code following the previous code isn’t carried out. This leaves only the forwarding information to be sent to the browser.

Single pages requiring forwarding are best suited for the method/code above. Whole websites should use alternate methods. You will need to add the code at the very start of the page’s PHP file. Check that there are no spaces or other characters before the opening <?php or the code will not function and you will instead receive a warning.

Implementing 301 Redirection with Apache mod_rewrite

The mod_rewrite is one of Apache’s most powerful modules. The mod_rewrite allows for rewriting URLs. You can find more information at http://httpd.apache.org/docs/2.0/misc/rewriteguide.html. You can completely control where a URL lands by rewriting a URL. You can also use mod_rewrite to forward entire websites since this module works on a server level.

Check first if your web server supports the mod_rewrite module. You can either ask your web hosting provider or use the PHP phpinfo( )function (see http://www.php.net/phpinfo). If your server does support mod_rewrite, you will need to add the code below to your .htaccess file (details to follow).

Use the code below to forward yourwebsite.com to www.yourwebsite.com.

RewriteEngine On

RewriteCond %{HTTP_HOST} ^yourwebsite\.com [nc]

RewriteRule (.*) http://www.yourwebsite.com/$1 [R=301,L]

And to forward www.yourname.com to yourwebsite.com, use the code below.

RewriteEngine On

RewriteCond %{HTTP_HOST} ^www\.yourwebsite\.com [nc]

RewriteRule (.*) http://yourwebsite.com/$1 [R=301,L]

Why Use the .htaccess File

The .htaccess files can be used to optimize the Apache web server configuration while the server is running. While it is a versatile tool, misuse of .htaccess files can also cause website errors. Use it with care.

Where you place the .htaccess file decides the extent of its effects.

1. If placed in the document root, it will affect your whole website.

2. If placed in a subdirectory, it only affects the subdirectory and its contents.

The .htaccess file is a simple text file, so edit it using a simple good text editor. Since the .htaccess file is just a simple text document, you can conveniently use any simple text editor to edit it.

Conclusion

As you have read, being proactive about problems that may lower your search engine ranking is not too difficult. Implementation of 301 Redirection is a simple and easy way to make sure your website and ranking is protected. In fact, 301 Redirection is the single correct way to address 301 Sabotage and other issues, whether intentional or not, that may threaten your search engine ranking.

This tutorial has covered the three methods (PHP, mod_rewrite, and .htaccess) for 301 Redirect. Furthermore, many web hosting companies save you the trouble and automatically do these for you. Make sure to use the instructions above to see whether your website is susceptible.