1. Home
  2. Computing & Technology
  3. Web Design / HTML

How To Set Up a 302 Redirect with HTAccess on Apache

By Jennifer Kyrnin, About.com

If you want to set up a temporary redirect to help your pages rank better in search engines, you should set up a 302 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.
  2. At the bottom of the file, add the line:
    Redirect 302 /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. You should only use 302 redirects to set up temporary redirects, such as to clean up ugly URLs.
  2. If you want the URL to change in the search engine, use a 301 redirect.

What You Need:

  • HTAccess
More Web Design / HTML How To's

Explore Web Design / HTML

More from About.com

  1. Home
  2. Computing & Technology
  3. Web Design / HTML
  4. Web Server Management
  5. HTAccess
  6. How to Set Up a 302 Redirect with HTAccess on Apache

©2008 About.com, a part of The New York Times Company.

All rights reserved.