Home Lessons & Videos Site Building Intermediate How to Move Your Pages With 301 Redirects

How to Move Your Pages With 301 Redirects

Affilorama members only


Watch a preview Join for free

How to Move Your Pages With 301 Redirects

2008-11-06 02:17:58

In this lesson we look at how to move your pages with 301 redirects

When to use a 301 Redirect

Imagine you've got a page on your website that has attracted a whole lot of good links, and is attracting a lot of traffic, but you need to move it to a different place on your website. You probably don't want to outright delete the page and simply recreate it somewhere else - you'll lose all those great links and all that PageRank as well.

The solution is the 301 Redirect. This takes all traffic and links arriving at your old page and redirects them to the new page; your links are safe, your PageRank is safe and your visitors still get to where they need to be.

The .htaccess method

301 Redirects can be created in several ways; the preferred method is by using your .htaccess file (if you're using an Apache server, which you probably will be)

First, make sure you've created your new page!

Then open (or create, if it doesn't exist) the .htaccess file in the same directory as your page, and paste the following code:

Redirect 301 /my-page.php http://www.example.com/new-page.php

Save this, upload, and your redirect should be in place! Easy as that! This method is the most powerful because you can redirect entire folders/directories, or even entire websites with it, e.g.

Redirect 301 /current-directory http://www.example.com/new-directory

The PHP method

If you're not sure how to edit your .htaccess file there is an alternative method: using a PHP file.

Move or delete your old page (e.g. rename 'my-page.php' to 'my-page-old.php'), create a new page with the same name (i.e. create a new page called 'my-page.php') and paste in the following code:

Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.example.com/new-page.php" );

When you save the page, you have to save it as a .php page. You also need to be sure that there's no .html version of the same page in the same place, because the web server may use the .html version instead of this one.

Once you've got all that, upload the page, and the redirect should start working immediately!

Note that this method is only good for redirecting one page, and only works on php pages. (If you need to redirect multiple pages you must replace each page you want to redirect)

Lesson Summary

In this lesson we looked at ways to redirect your page without losing all of its links or PageRank. The two methods we looked at were:

  • Using a .htaccess redirect
  • Using a PHP file


Learn something new? Share it with your friends!


Questions & Comments + Add a comment

  • Anatomy of a Web Page #2 In this lesson we're going to look at a few more elements that make up your average web page, as well as a brief intr...
  • How to hide your affiliate link with ... Affiliate links are ugly, and can sometimes put people off clicking them. In this lesson we look at making your links...
  • Simplifying Navigation with PHP Includes Websites with more than one page can be a pain to update. However, 'PHP includes' allow you to change multiple pages ...
  • Date Scripts What better way to get your visitors to act now than to give them a deadline? "Act now! This offer expires tomorrow!"...
  • Sitemaps When you become desperate to find a particular page on a site, you need to refer to the sitemap. Learn what it does, ...
  • URL Canonicalization – To www or not ... Why are www.example.com and example.com not the same website? We take a look at what that "www" means for you as an a...
  • Robots.txt - Telling the search engin... To index your site, search engines send spiders to crawl all your content to check for relevant information. But what...
  • How to create a rollover button In this lesson we'll be explaining the steps involved in creating a rollover button and how to add it to a page on yo...

Don't forget to follow us!

More topics

Essential Resources Every New Affilia... New to affiliate marketing? Not sure what it's all about? Then let us get you started!
Affiliate Outsourcing No one person can do everything on their own. Learn how to reduce (or even eliminate!) your workload with outsourcing.
Site Building As an affiliate, chances are you'll end up building a website or two. Here's your basic quickstart!
Marketing Ideas Needing inspiration? Wanting to go outside the box? Take a look in here for your next few marketing ideas!
Market Research for Affiliate Marketers To be a successful affiliate you must learn how to research their market before dedicating your precious time.
Pay Per Click Pay-per-click is one major method affiliates use to get traffic. Learn what it is and how you can use it effectively!
Search Engine Optimization Search engine optimization (SEO) is a major way of getting traffic to your site at minimal cost! Learn how to put it ...
Content Creation This section is all about content: How to write it, how to get it written for you, and other useful goodies!