Thursday, August 18, 2016

How to Properly Implement a 301 Redirect

How to Properly Implement a 301 Redirect was originally published on BruceClay.com, home of expert search engine optimization tips.

What is a 301 Redirect?

A 301 redirect is a command used to tell the search engines that a page has permanently moved, and that you want them to index the new page and drop the old one from their index.

Think of it as a change of address card for the web. As long as everything is done correctly, a 301 redirect will ensure that you keep the rankings earned by the old page and it will prevent duplicate content that should arise if the engines were to index both versions of your site.

Read on to learn how to:

How to Implement 301 Redirects Using .htaccess for Apache

Make sure you have access to your server and your Apache Configuration file, and that you can use your .htaccess files. The ability to use .htaccess files will reside in a command called “Allow Override” in the Apache Configuration file. If you do not have this access, you’ll have to first call your hosting company and get access.

Once you know that you have access to this file, your next step is to locate it. The .htaccess file is a control file that allows server configuration changes on a per-directory basis. It controls that directory and all of the sub-directories contained within. In most cases, this file will be placed in the root web folder for your site. If there’s no .htaccess file present, create one.

To begin using the .htaccess file to redirect page(s) on your site, open up your FTP and login to your site. Work your way into in the root web folder in order to access your .htaccess file.

(Note: the dot in .htaccess makes it a hidden file, so make sure your FTP browser is enabled to view hidden files.)

When you start editing the file, use a UNIX style text editor rather than Notepad. Typically, an HTML editor or code editor such as TextPad works just fine. To 301 redirect pages using the .htaccess file, you will add a line to the file that will tell the server what to do.

301 Redirect a Page

RedirectPermanent /old-file.html http://www.domain.com/new-file.html

301 Redirect an Entire Domain

RedirectPermanent / http://www.new-domain.com/

Once you have inserted the commands to 301 redirect your pages, you need to make sure that there is a blank line at the end of the file. Your server will read the .htaccess file line by line, which means at some point you’ll need to throw them an “endline” character to let them know you’re finished. An easy way to do this is to put a blank line at the bottom of the file.

How to Do a 301 Redirect Using IIS on a Microsoft Windows Server

Navigate your way to Internet Information Services (IIS) Manager, which is found with Administrative Tools within the Start menu. From there, you will find a panel on the left-hand side that lists all your sites. Choose the site you want to work on.

Once you select it, several modules come up. Verify the URL Rewrite module is present. If it is not, you can install it here. Once you have it, double click to open the module. On the right hand side, you will see an option to Add Rules. Click it and then select Blank Rule under the Inbound Rules section. Hit OK. This will take you to an Edit Inbound Rule page. Type a name for the rule, such as Old Domain Redirect or Old Page Redirect.

Go to Match URL Panel. Set the requested ULR at “Matches the Pattern” and the Using as Regular Expressions. Now you will specify if you’re redirecting a single page, a group of pages or an entire domain. What you input

  • To redirect a single page, type in the page name under Pattern (for example, if we were redirecting this blog post, we would input blog/how-to-properly-implement-a-301-redirect/ in the pattern field.
  • If we were redirecting the entire site, we would input (.*) in the Pattern field.
  • If we redirecting all the pages on BruceClay.com within the SEO folder, we would input seo/(.*)

Make sure ignore case is checked.

Skip down to the action panel and select Redirect within the Action Type dropdown. In the Action Properties, type in the new URL. If it’s a single page, input the single page. It’s if the entire domain or a group of pages, type the new destination with a back reference, which is {R:0}. The back reference will keep all page URLs intact with the new domain.

For example, if we were changing BruceClay.com to BCI.com, we would input http://www.bci.com/{R:0}

If you use tracking parameters and you want them to carry through, check Append Query String.

In the Redirect type filed, select Permanent (301).

Click Apply at the top right in the Actions column to save the redirect.

(If you want to review the redirect, hit back to rules in the Right Actions column)

After you save this redirect, the rules you created are save into the web.config file, which you can edit in the future.

Alternative Methods to Implement a 301 Redirect

If you don’t have access to your .htaccess file or your Windows Server Administration Panel, you can still implement 301 redirects with code on your old pages. If your pages are in PHP, ASP, Java, or any other language that allows you to modify Response Headers, simply place code at the top of each page to do the Permanent Redirect.

Why to Implement a 301 Redirect

There are many times a 301 redirect makes sense. Here are a few of the most common:

  • You’re changing your entire root domain.
  • You want to reorganize pages. For example, we used to index blog posts by category. For example, this blog post used to exist as www.bruceclay.com/blog/seo/how-to-properly-implement-a-301-redirect/. There were directories for SEO, SMM, PPC, content, etc. At some point, we decided it would advantageous to remove those directories, and as you can see now, the current URL is http://www.bruceclay.com/blog/how-to-properly-implement-a-301-redirect/.
  • Let’s say CNN posted a link to this blog post, but the URL was incorrect. We’d still want that traffic that is going to a 404 page. We can put in a 301 redirect to direct users from the bad link the right link.
  • You want a vanity URL.

Note: If you concerned you’re going to lose PageRank, know that any fluctuations will be temporary. Google Webmaster Trends Analyst Gary Illyes recently commented:


Have any questions about implementing a 301 redirect? Ask us in the comments and we’ll be happy to help you.

No comments:

Post a Comment