How To Redirect My Old Web Pages - 301 Redirect

How to Redirect an Old Web Page to Your New Page using a 301 Redirect.

Planning on upgrading your website, or moving web or even renaming particular web pages and or files?
Here is the issue you will have to deal with:

Google, Yahoo, Bing and other search engines have indexed your entire web site and you're going to move or rename your pages. By altering these pages(files), you run the risk of losing a lot of traffic and leaving visitors to your site who follow a search engine link with the dreadful "File Note Found - Error 404".

To solve this issue, the 301 redirect is the best tool to use. More information is given below on how to do this, but first let's take a look at a couple of other strategies often see mentioned around the internet to get around the problem and why they shouldn't be used.

Custom Error Page

A custom error page could be created. The problem with this solution:

NOTE: We do recommend Custom Error Pages if they are used for pages that have never existed. It is better to have control over a wrong URL typed in by a visitor to your site then see the bland generic browser generated 404 Error Page Can't be found page, however

a) Your page if someone follows a link and lands on it, the old web page file will not be available; the file will appear to be non-existent next time it's requested by the search engine spider. It could be some time before the page in its new location or with a new name reappears and given you'll lose the power of inbound links from other sites to the page in question, more than likely it will not rank.

b) Visitors t to your web page may be frustrated by the fact that they then have to dig through your site to find the desired information. (We would be assuming that they wanted a specific page)

Meta Refresh

By placing a blank web page and naming it the same as your old file (page name) you can place a meta refresh code in blank page. This will automatically redirect visitors to the new page. Here is an Example:

Warning: Spammers often use this technique to trick search engines and it should be avoided, unless the page is in a part of your web site that isn't visited by search engine "spiders".

What search engine spammers do is to create a web page that is optimized for certain phrases and keywords - it usually has no real content. The web page is then noticed by search engines, but when a visitor clicks on the search engine entry, they are redirected to another web page or even web site, often unrelated.

It's a despicable trick, but thankfully most search engines have filters to detect this. Using this form of search engine deception will see a web page or even web site eventually banned or penalized by major players such as Google and Yahoo.

A work around is to create a "ROBOTS" statement in the code example above which tells search engines to ignore this page, a safeguard against getting a slap from the engine.

Aside from what would appear as a spam issue, this approach also has the disadvantages of using a custom error page

The Correct Way - a htaccess 301 Redirect

One of the most efficient and search engine spider and visitor friendly strategy around for web sites that are hosted on servers running Apache (all KARTHOST servers run apache) A 301 redirect is the most efficient redirecting search engine spider/visitor visitors to your site.

To implement a 301 Redirect isn't that hard to do, it should preserve your search engine rankings for that web page. If you "have" to change file names or move pages around, it's the safest solution.

A 301 redirect is implemented in your .htaccess file.

What is a .htaccess file?

When a visitor/ search engine spider requests a web page via any means, the web server checks for a .htaccess file. The .htaccess file contains specific instructions for certain requests, including security, redirection issues and how to handle certain errors.

What is a 301 redirect?

The code "301" is understood as "moved permanently". After the code, the URL(the full web address to the page) of the missing or renamed page is noted, followed by a space, then followed by the new location or file name

Implementing a 301 redirect for static pages

You will first need to look to see if you already have a htaccess file in your root directory (actually htaccess files can be in any directory but they control only that directory). You'll need to download the .htaccess file in the root directory of where all your web pages are stored (This would be the /public_html directory for all KARTHOST Servers). If there is no .htaccess file there, you can create one with Notepad or a similar application (a good one is can be found here www.pspad.com/en/). Make sure when you name the file that you remember to put the "." at the beginning of the file name. This file has no tail extension. (if using notepad you will have to save it as a .txt file once saved use your computers file manager to remove the ".txt" extension)

VERY IMPORTANT - If there is an .htaccess file already in existence with lines of code present, be very careful not to change any existing line unless you are familiar with the functions of the file.

Scroll down past all the existing code, leave a line space, and then create a new line that follows this example:

redirect 301 /old/old.htm http://www.you.com/new.htm

Really it's as easy as that. Save the file, upload it back into your site and test it out by typing in the old address to the page you've changed. You should be instantly and seamlessly transported to the new location.

VERY IMPORTANT - Be sure not to add "http://www" to the first part of the statement - just put the path from the top level of your site to the page. Also ensure that you leave a single space between these elements:

redirect 301 (the instruction that the page has moved)

/your-old/your-old.htm (the original folder path and file name of course you place your actual directory and file name here)

http://www.yoursite.com/new.html (new path and file name)
Implementing a 301 redirect for dynamic pages

A dynamic page is one generated by a database driven application, such as a shopping cart, forum or blog web based software. A file name is appended by a query string, looking something like this:

http://www.just-an-example.com/page.php?id=13

Where a query string is used, the 301 redirect solution for static pages above will not work; you'll need to use a rewrite solution. Using the page.php?id=18 example, here's what you'll need to use in your htaccess file:

RewriteEngine on
RewriteCond %{QUERY_STRING} ^id=18$
RewriteRule ^/page.php$ http://www. just-an-example.com/yournewname.html? [L,R=301]

In the example above the id=18 should be replaced with the query string of the page you wish to redirect and the page.php with the name of your file prior to the query string.

A more powerful set of directives for manipulating URLs is contained in the Apache mod_rewrite module, especially useful when changing domain names and/or folder names containing large numbers of files.

301 redirect for file names with spaces

If you have file names with a space you wish to redirect, for example "my old page.htm", a standard redirect 301 line won't work, but by using quotes around the original file path, it will then function correctly.

Example:

redirect 301 "/my old page.htm" http://www. just-an-example.com/newpage.htm
Redirecting entire sites with 301

The 301 directive is quite powerful. You can redirect not just single files but entire sites, for example when changing domain names e.g.

redirect 301 / http://www.your-new-site.com/

The first "/" indicates that everything from the top level of the site down should be redirected. As long as you are using the same paths and filenames, then this option is a very simple way to perform site redirection in the situation where you have only changed your domain name.

If the site redirection doesn't work for you, check to ensure you have the trailing "/" on the destination URL.

With a lot of talk going around about canonical issues and search engines, you might find this interesting. canonical is where both the www and non-www versions of your pages are listed in a search engine. This is said to possibly trigger a duplicate content penalty and/or split page rank. If this is of concern to you, you may wish to use the following, but be aware that you may suffer a further loss of traffic while the engines sort out what's what. This example is where you wish to direct all non-www traffic to www. Add the following to your .htaccess file.

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^your-current-site.com [NC]
RewriteRule ^(.*)$ http://www.your-current-site.com/$1 [L,R=301]

Ensure that all your links to folders always end in a trailing / if there is no filename after that link.

VERY IMPORTANT - FrontPage users: in addition to the above, you'll also need to change the .htaccess files in:

_vti_bin
_vti_bin /_vti_adm
_vti_bin/ _vti_aut

Replace "Options None" to "Options +FollowSymLinks"

Those folders are part of your FrontPage extensions on the server, so you'll need to gain access via FTP.
(Don't you just LOVE FrontPage Extensions?)

Note: There are several things you will need to do......1) test, 2) test and 3) test again after making changes. Test immediately after implementing 301 redirects. If you find anything wrong, remove the redirect immediately. User a server header checker to ensure that you're getting a correct 301 response when using the old URL.

The 301 redirect is the safest way to preserve your rankings. On the next search engine spidering, the search engine robot will obey the rule indicated in your .htaccess file. The search engine spider doesn't actually read the .htaccess file, but recognizes the response from the server as valid.

With the next update, the old file name and path should be dropped and replaced with the new one. Sometimes you may see alternating old/new file names during the transition period, along with some possible fluctuations in rankings as things settle. Don't panic - this is normal and may take a number of days or even weeks before everything is back to normal; but the bottom line is, any change you make has risks - whether it's altering page text, moving/renaming pages or changing domain names. Search engines run by their own rules and can change those rules at any time.

If you're changing domain names and using a 301 redirect, you'll need to leave the old domain name and files in place for a few weeks to give the major search engines time to catch on to the changes and don't forget to notify your link partners of the domain name change as soon as possible. Once you deactivate the old domain, any search engine kudos you've built up over the years through those links will be gone.

  • 11 Users Found This Useful
Was this answer helpful?