Set Up 301 Redirects Using .htaccess

From FRII Support

Jump to: navigation, search
Support Resources

General Resources
CPanel Hosting
Retail MailArmory (New)
Skybeam Wireless
Transfort WiFi
Web Hosting


Please note: The following information is provided by FRII as a courtesy. Although Front Range Internet does not provide technical support for this service, please contact us if you are unable to resolve your question. We will do our best in directing you to resources that can better assist you.

LightBulb.png Requirements: Select Hosting with Unix Add on or better

What is a 301 Redirect?

A 301 redirect is the preferred method to preserve your current search engine rankings when redirecting web pages or a web site. The code "301" means that the page has "moved permanently".

Set Up the 301 Redirect

  1. To create a .htaccess file: open notepad, name and save the file as .htaccess (be careful not to save the file as .txt).
    • If you already have a .htaccess file on your server, download it to your desktop for editing.
  2. Copy this code into your .htaccess file:
    redirect 301 old.htm http://www.domain.tld/new.htm
  3. If the .htaccess file already has lines of code in it, skip a line first.
  4. Save the .htaccess file.
  5. Upload this file to the root folder of your server.
  6. To test it, simply try to load the old site or page in your browser. You should be redirected immediately.

LightBulb.png Don't add "http://www.domain.tld" to the old page url.

Other Ways to Implement the 301 Redirect

  • To redirect ALL files on your domain use this in your .htaccess file:
redirectMatch 301 ^(.*)$ http://www.domain.tld
redirectMatch permanent ^(.*)$ http://www.domain.tld
  • You can also use one of these in your .htaccess file:
redirect 301 /index.html http://www.domain.tld/index.html
redirect permanent /index.html http://www.domain.tld/index.html
redirectpermanent /index.html http://www.domain.tld/index.html

This will redirect "index.html" to another domain using a 301-moved permanently redirect.

  • If you need to redirect http://domain.tld to http://www.domain.tld put this in your .htaccess file:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule ^(.*)$$1 [R=permanent,L]
  • or this:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.tld/$1 [R=301,L]
  • If you want to redirect your .html pages to .php pages put this in your .htaccess file:
RewriteEngine on
RewriteBase /
RewriteRule (.*).html$ /$1.php
Personal tools