DIY SEO: 301 Redirect E-Commerce SEO Guide
There are many reasons why you might need to use redirection for your E-Commerce website. Let’s assume that you decided to move your store to a new domain, but you are afraid that you might lose your traffic and your hardly acquired search engine ranks. Or, you could have several URL’s allowing users to reach your website in various ways, like, for instance, http://website.com/home, http://website.com, http://home.website.com. In this case, you might want to become more selective and choose one to be your primary URL. Or, you could have several websites which you might want to merge into one comprehensive website and you could need to find a way to safely redirect your old links to different URLs. All these issues can be easily solved by using one of the most proven SEO tactics that is still actively adopted by numerous E-Commerce businesses, and it’s called 301 redirect. We included everything you need to know about 301 redirect and its SEO profits in our ultimate guide. Please note that the following DIY SEO guide is aimed at various E-Commerce platforms, so you can easily leverage the power of the Magento 301 redirect by reading the following information.
Table of contents
- 1 Redirection
- 2 So, what is 301 redirect?
- 3 Where to perform 301 redirects?
- 4 Setting up your 301 redirect
- 5 Don’t forget about backup
- 6 Using 301 redirect for specific purposes
- 6.1 Redirecting an old page to a new page
- 6.2 Redirecting a home page
- 6.3 Redirecting files to a new domain
- 6.4 Redirecting folders and categories by changing their name
- 6.5 Redirecting categories to a single page
- 6.6 Redirecting a non-www website to a www website
- 6.7 Redirecting old files to a new server without preserving their names
- 6.8 Redirecting to new PHP scripts with preserving GET strings
- 6.9 Redirecting files with different extensions
- 7 Troubleshooting
Redirection
Before we reach an actual investigation of 301 redirect, a few words should be devoted to redirection in general. Basically, redirection is a set of HTTP status codes representing one essential process – forwarding the given link (or links) to a different web address. This can be done through the following types of redirects:
- 301, or “moved permanently”;
- 302, or “moved temporarily” (in HTTP 1.0) / “found” (in HTTP 1.1);
- 307, an updated version of 302 redirect, available only in HTTP 1.1;
- Meta Refresh.
Redirects are actual ways of performing redirection. They simply get visitors and search engine bots from the page they originally entered to a different URL.
302 and 307 redirects are considered temporary redirect types which forward a user or a crawler to a different page by pointing that this change is not permanent. For instance, you could apply either 302 or 307 redirect for a period of several days in case of, say, unexpected maintenance work on your website. Later on, you can easily get back to the original URL. Although 302 and 307 redirects are technically different, their ultimate function is essentially the same.
Meta refresh redirect type provides slower redirection and is often found on security prioritized websites using a lot of external URLs on their pages. This type of redirect is often called time-delay redirect shown as a 5-second countdown. These five seconds are needed for a prior load of the original URL.
While 302, 307, and meta refresh redirect types can be of use to a web developer, they transfer no or too little SEO authority from the original web page to the new one, which makes them inefficient for traffic-concerned E-Commerce website owners. Thus, only 301 redirect can be called an important SEO tool that allows for the safest site-to-site transition with minimal risk for your rankings.
So, what is 301 redirect?
Unlike other redirects, 301 is a permanent redirect type, i.e. a status code telling that a current page has been permanently moved to a new location or URL. Not only single pages but also entire websites can be redirected from one URL to another. The main advantage of 301 redirect lies in its ability to transfer up to 99% of ranking power to a new address, which means that your new URL will be as visible to search engines and visitors as your old URL once was. This is also the fastest way to inform search engines about the changes in your Internet location. You should note, however, that a certain time is still needed for redirected pages or websites to get updated in search engine results through indexing which would allow them to be properly displayed on search result pages.
Where to perform 301 redirects?
To perform redirection through 301 redirect, you will need to open your .htaccess file which can be found in the root directory of your website (/public_html). All commands from .htaccess are usually implemented during every opening of a link thus allowing it to be fully loaded. However, there are cases when a website can have no .htaccess file at all. You can create or edit your .htaccess file by using a default text editor on your computer, but remember not to include any extensions to the output file. The resulting file can be then added to the root directory again.
Setting up your 301 redirect
To set up a typical Apache-based 301 redirect for Magento or any other E-Commerce website, you need to open your .htaccess file and insert the necessary code fragment. Make sure that you have previously installed and activated the mod_rewrite module. The following line should be inserted before the actual 301 redirect commands:
1 |
RewriteEngine On |
To be able to write 301 redirect commands, you will need to utilize regular expressions or regexes. These are strings of code that define search patterns for describing and matching strings. For performing redirection you will only need to use some of the regexes’ characters and operators:
- . Period – matches any character;
- * Asterisk – a quantifier that matches zero or more of the preceding characters;
- + Plus – a quantifier that matches one or more of the preceding characters;
- ( ) Parenthesis – a back-reference, used to reserve matched variables for future use;
- (value1|value2) Vertical pipe – separates a set of alternatives.
To make your 301 redirect commands work properly, include the following introductory lines to your .htaccess file:
1 2 |
Options +FollowSymlinks RewriteEngine on |
The first line here indicates that the mod_rewrite module is enabled.
Don’t forget about backup
Because search engines are capable of fast indexing, you need to be sure that every change you make to your website or its separate pages is correct. So, before proceeding to tests with 301 redirect, take care of the following:
- You will certainly have to create a backup copy of your .htaccess file in case if you might accidentally delete some or all of the already existing commands;
- Only start testing at the period of having the least activity on your website – for instance, after midnight;
- If your tests fail and you get 500 error over and over again, don’t hesitate to restore your .htaccess file with a backed-up version. However, in most cases the problem is just one single character missing;
- Perform all tests on a staging site if you have one. If not, you can create a staging account on the server by copying a mirror version of your website to it. You should also block any search engine access to it. In fact, a staging site is a perfect testing platform for all SEO issues.
- Check whether your old links forward you to the right location on your new website. If you have dozens of link redirects, be consistent in checking at least half of the overall amount.
- It’s crucial to remember that changing a domain name will impact your old backlinks. Because it can be thousands of backlinks, it is in most cases impossible to update all of them manually, which can lead to a loss of your rankings.
Using 301 redirect for specific purposes
Depending on your actual aims, you might need to use 301 redirect to perform various scenarios while redirecting users from one link to another. Here is the list of the most frequently used scenarios and tips on their proper implementation.
Redirecting an old page to a new page
This is the simplest instance of 301 redirect scenario which allows you to redirect one of the pages of your old site to the corresponding page on your new site. Let’s assume that your original URL is www.old-site.com/old.html, and you need to redirect it to www.new-site.com/new.html. The required directive is:
1 |
Redirect 301 /old.html http://www.new-site.com/new.html, |
where /old.html corresponds to the URL being directed. You should note that, while all links that are being redirected can be reduced to the page itself, final 301 redirect destinations need to always be written in their full form.
The same line can be used to redirect pages that have no particular extension, like WordPress pages, for instance:
1 |
Redirect 301 /old http://www.new-site.com/new |
Redirecting a home page
This scenario supposes that you need to provide redirection of a single page without any additional elements of your website. In this case you can use a different type of directive:
1 |
RedirectMatch ^/$ http://www.new-site.com |
Redirecting files to a new domain
You can transfer all your files and folders from your old domain to the new one by causing no changes to the original file names. So if your original file destination looked like this:
http://www.old-site.com/folder/yourfile.php
you might want to redirect it to:
http://www.new-site/yourfile.php
For this, you should add the following directive to your .htaccess file:
1 |
RedirectMatch 301 /folder/(.*) /$1 |
This regex requires Apache to match a specific folder followed by zero or more of any characters. Parenthesis around it means that an enclosed string is preserved as a back-reference which, in our case, is redirected to $1.
Redirecting folders and categories by changing their name
There are cases when you want to change the name of one or more categories. For instance, you might have restructured the whole category tree on your new website and need to specify the name of a certain type of products. Or, you have realized that you need to generalize the category due to having too little items in it. Then the line you need to include to you .htaccess file will look as follows:
1 |
redirect 301 /oldcategory/ http://www.new-site.com/newcategory/ |
You can also add a subcategory to your new URL:
1 |
redirect 301 /oldcategory/subcategory/ http://www.new-site.com/newcategory/1subcategory/2subcategory/ |
Note that original categories should be written with slash symbols on both sides of the word because they mean “folder” in the regex syntax.
Redirecting categories to a single page
Apart from redirecting old categories to new ones, there is also a possibility of redirecting existing categories to a plain web page. As a result, both a folder and its contents can be redirected to the main page of your website. To do that, use the following line:
1 |
RedirectMatch 301 ^/categoryname/(.*)$ http://www.new-site.com/new-page.html |
Redirecting a non-www website to a www website
This is one of the most frequently used scenarios for 301 redirects. It is common for search engines to have issues with websites having one or more alternative URLs, which often leads to poor SEO results. If you want to switch to a www-version, include the following snippet:
1 2 |
RewriteCond %{HTTP_HOST} *!^www*.new-site.com [NC] RewriteRule (.*) http://www.new-site.com/$1 [L,R=301] |
In this case, you tell Apache to analyze the given host and, if it happens not to be equal to www.new-site.com, to perform Rewrite Rule and redirect the user to the latter address. [NC] literally means “not case-sensitive” thus allowing for a wide domain variation. L character indicates the end of a current line, which means that anything that goes after it will not be considered as “set”.
This scenario, by the way, provides for preservation of the original file names.
Redirecting old files to a new server without preserving their names
Some of the files you used in the old version of our website may be absent on the newly created one. If you need to still keep an access to those files, you can redirect them to the root address of your new domain:
1 |
RedirectMatch 301 /folder/oldfile.php http://www.new-site.com |
Apache will interpret this line as an instruction to redirect all requests for /folder/oldfile.php to a new location, namely http://www.new-site.com.
Redirecting to new PHP scripts with preserving GET strings
Preserving GET request strings is as important for successful redirection as using 301 redirects in general. GET strings are those characters that follow a name of the file in the link and are used to specify data for a website. They usually look as follows:
1 |
/myfile.php?this=that&foo=bar would be “?this=that&foo=bar.” |
It is essentially useful for redirecting product or category pages.
For this scenario, the following line can be added:
1 |
RedirectMatch 301 /somestuff/categorydetail.php(.*) http://www.new-site.com/artcat.php$1 |
Redirecting files with different extensions
Sometimes you may face the problem of having different file extensions in the old and new version of your website. For instance, your original file folder consists of 50% of PHP files and 50% of HTML files, while the same folder on the new website contains the same files but all in PHP. To overcome this, use this directive:
RedirectMatch 301 /category/somefolder/(.*)\.(php|html) http://www.new-site.com/somefolder/$1.php
Here, (php|html) is used to match a dot followed by either php or html. A backslash (\) allows Apache to perceive the following dot as an actual period rather than any character, as it was stated before. A vertical pipe (|) divides the two values thus telling Apache to match either one or the other.
Troubleshooting
Even though you may have implemented your 301 redirect properly, sometimes you can still get unexpected issues on the go. Let’s look at the most frequently occurring problems with maintaining 301 redirects.
Your rankings drop sometime after launching 301 redirect
First of all, check the entire website or its separate pages for search engine relevance. It may be the issue with preserving SEO features that worked well on your original website. So if your old website content used to be relevant, you should in no way give it up for your new website.
As it has been said before, 301 redirects transmit 90-99% of ranking power to your new website. However, it is generally normal to have a 15% drop in traffic after you move to a new location.
The redirected page was penalized by Google
This is the case when you try to redirect any page that has been penalized before you applied 301 redirect to it. Unfortunately, Google algorithms are trained to be strict to any attempt of a user to bring back good rankings of their penalized pages through redirection. However, it is likely that your pages will be naturally recovered in a few years. Nevertheless, it is perhaps not the best strategy at all.
You’re not sure when to deactivate your 301 redirect
Generally, it takes around a year to let search engines and users adjusted to your new website location. But there is nothing wrong with keeping redirection active for a longer period.
We hope to have provided you with the most relevant information regarding 301 redirects. Feel free to choose and try one of the 301 redirect strategies that suit your personal E-Commerce needs and don’t forget that the aforementioned information is suitable for Magento. You can also watch the Google’s official video tutorial on setting and implementing a 301 redirect: