1. Computing

Discuss in my forum

How To Set Up a 301 Redirect with HTAccess on Apache

By , About.com Guide

If you want to redirect your web pages without penalizing them in search engines you should use a 301 Server Redirect. But you don't need server programming to set one up, just a simple text file on your Apache web server.

Difficulty: Average
Time Required: 5 minutes

Here's How:

  1. If you don't have a .htaccess file in your root directory, open a new text file. If you do have one there, open it for editing.

    Note: before you give up looking for your .htaccess file, you should make sure that you are viewing hidden files on your server. Also note that the .htaccess file starts with a period (.), and is not just called “htaccess”.

  2. At the end of the file, add the line:

    Redirect 301 /PATH_TO_REDIRECT NEW_LOCATION_URI
  3. Change /PATH_TO_REDIRECT to the directory path on your web server you want redirected.

  4. Change NEW_LOCATION_URI to the URL path you want the pages redirected to.

  5. Save your .htaccess file and upload it to the root of your web server.

  6. Test your redirect by going to the old path in a web browser. You should be taken automatically to the new path.

Tips:

  1. Always use 301 redirects rather than meta refresh tags. They are more search engine friendly.

  2. Remember that a 301 redirect tells people that this page has been permanently moved. If you have only moved the page temporarily, you should use a 302 redirect. You can do this the exact same way as above, just change the 301 to a 302.

    Redirect 302 /PATH_TO_REDIRECT NEW_LOCATION_URI

What You Need

  • HTAccess
  • Apache web server
  • text editor

©2013 About.com. All rights reserved.