Sorting Out Redirects
301 redirect: 301 is a command that tells the search engines the page has permanently moved. The response is to index the new page and drop to old page. This is the right way to move a page. It will maintain the ranking of the page and prevent duplicate content in the engines. If you are moving domains, this is the redirect to use. 301 redirects are key to the proper implementation of an IP funnel as well.
302 redirect: 302 is a temporary move. The message to the search engines is that the new page is only a temporary home and not a valid address for indexing. The response is to keep the old page and attribute the content on the new page to the original address. 302 redirects have been the subject of a great deal of interest following the problem of a rise in hijacking pages by 302 redirects. A 302 hijacking can be devastating to a site, causing duplicate content penalties and loss of ranking. For SEO purposes, there is no reason to use a 302 redirect.
In actuality when moving a page, you should always use a 301. There isn’t any good reason to move a page any other way if you want to preserve your web position. The way to do a 301 redirect depends on the type of server you have. Most Linux servers use Apache as the web server. Microsoft servers use IIS. We have included instructions on how to include a 301 on both types of servers.
How to do a 301 redirect using .htaccess for Apache.
Redirecting pages or sites with Apache is very easy, as long as you know how to use the .htaccess file.
The .htaccess file is a control file that allows server configuration changes on a per-directory basis. The file controls that directory and all of the sub-directories contained within. Most of the time, this file will be placed in the root web folder for your website.
Before you start, you should make sure that you can use .htaccess files. If you have access to your server and your Apache Configuration file, make sure that .htaccess files can be used. This will reside in a command called “Allow Override”. If you do not have this access, call your ISP and ask.
To use the .htaccess file to redirect page(s) on your website, open up your FTP and login to your website. In the root web folder, there should be a file called .htaccess. NOTE: If there is not a .htaccess file present, you may create one.
Edit the .htaccess file using a UNIX style text editor, not Notepad. Usually, an HTML editor or code editor such as TextPad will do the job. To 301 redirect pages using the .htaccess file, you will add a line to the file that will tell the server what to do. There are a couple ways to do this and they all accomplish the same thing.
RedirectPermanent /old-file.html http://www.domain.com/new-file.html
Redirect 301 /old-file.html http://www.domain.com/new-file.html
A redirection from one domain to another would be:
RedirectPermanent / http://www.new-domain.com/
There are some important things to note here:
- The first section of the command tells the server what to do: RedirectPermanent or Redirect 301. Again, these commands are equivalent.
- The second is the relative path to the file that you want to redirect. This must be the relative path to the location of the .htaccess file. If you place the file in your root web directory, then you can use the URL of the file without the domain name, i.e. /old-file.html. There is no need for the http:// etc.
- The last section is the full path to the new file. This is a fully qualified URL, i.e. http://www.domain.com/new-file.html
How to do a 301 redirect using IIS 5.0 and 6.0.
If you are on a Microsoft server, 301s can be a bit more complicated. Start the Internet Services Manager. Select the Website you wish to redirect from; right click and select properties from the context menu.
Click on the “Home Directory” tab and select “A redirection to a URL” from the radio buttons at the top. The menu screen should look similar to the one above.
Type in the new site that this site will point to and make sure that “A permanent redirection for this resource” is selected. There are other checkboxes that handle some different options, depending on what you want to do: “The exact URL entered above” – This will redirect the user (or search engine bot) to the exact page as you entered in the “Redirect To:” box. For Example, if this was checked, and somebody went to http://www.youroldsite.com/products/index.html, they would go to http://www.yournewsite.com/.
“A directory below this one” – this option will redirect a parent directory to a child directory. If someone were to type in http://www.yoursite.com to access the site and you wanted the request to be redirected to a child directory named “apps”, then they would be sent to http://www.yoursite.com/apps. To set this option, type in the name of the subdirectory in the URL textbox. “A permanent redirection for this resource” – This is to tell the browser that this is a 301 – Permanent Redirect. This will update bookmarks as well as search engine indexes of the old page.
There are also some control variables that you can pass to the “redirect to:” URL name to have more options of what you are redirecting.
Passes parameters that were passed to the URL to the new URL.
If the request contains parameters such as http://www.yoursite.com/mypage.asp?Param1=1 then $P would represent all the values after the question mark in the URL, example $P would equal Param1=1.
Passes the parameters including the question mark.
This is the same as $P but includes the question mark. So $P would equal ?Param1=1
Passes the matching suffix of the URL to the new URL.
If the request is for http://www.yoursite.com/mydir/mypage.asp, then $S represents /mypage.asp. If the request was for http://www.yoursite.com/mydir then the value of $S would be /mydir
Removes the server name from the original request.
If the request is for http://www.yoursite.com/mydir/mypage.asp then $V would contain everything after the server name, ex: /mydir/mypage.asp.
Wildcard symbol used for replacement.
Say for instance you want to redirect all requests for html pages to a single asp page you could do so in the following way: *;*.htm;myasp.asp
For domain redirections, $V is the most useful. If the directory structures and page names are all the same, and only the domain has changed, then in the “redirect to:” text box, you would have something like “http://www.yournewsite.com$V”. This will redirect all directories and page names from the old site to the new one as long as they are the same. For Example, http://www.youroldsite/directory1/page1.html would redirect to http://www.yourNEWsite.com/directory1/page1.html. Leaving this control variable out will only redirect the home page. If other pages are ranked in your site, then it would be extremely helpful to redirect those pages using these variables also.
To finish, press “apply” and “ok” and the redirection will be put into place. That’s it!
Variables table from this article.