Something Different In Linux

Home » How to » How to Redirect a Web Page Using a 301 Redirect

How to Redirect a Web Page Using a 301 Redirect

Posted by Rishikesh Vispute Categories: How to, Knowledge

How to Redirect a Web Page Using a 301 Redirect

You’ve just edited or modified some pages of your web site and those pages
have high search engine rankings that you don’t want
to lose. How can you safely redirect web site traffic from
your old pages to the new pages without losing your
rankings? You can do this by using a ” 301 redirect “.

Introduction to “What is 301 redirect?”

301 redirect is the best method to maintain your current
search engine rankings when redirecting web pages or a web
site. The code “301” is interpreted as “moved permanently”.
After the code, the URL of the missing or renamed page is
noted, followed by a space, then followed by the new
location or file name. You implement the 301 redirect by
creating a .htaccess file.

What is a .htaccess file?

An htaccess file is a simple ascii text file which you create or edit in a text editor. The dot (.) before the word htaccess indicates that .htaccess is  a file extension.When a visitor/spider requests a web page, your 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

How to implement the 301 Redirect

1. To create a .htaccess file, open notepad, name and save
the file as .htaccess (there is no extension).

2. If you already have a .htaccess file on your server,
download it to your desktop for editing.

3. Place this code in your .htaccess file:

redirect 301 /old/old.htm

4. If the .htaccess file already has lines of code in it,
skip a line, then add the above code.

5. Save the .htaccess file

6. Upload this file to the root folder of your server.

7. Test it by typing in the old address to the page you’ve
changed. You should be immediately taken to the new

Notes: Don’t add “http://www” to the first part of the
statement – place 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)

/old/old.htm (the original folder path and file name) (new path and file name)

When the search engines spider your site again they will
follow the rule you have created in your .htaccess file.
The search engine spider doesn’t actually read the
.htaccess file, but recognizes the response from the
server as valid.

During the next update, the old file name and path will be
dropped and replaced with the new one. Sometimes you may
see alternating old/new file names during the transition
period, plus some fluctuations in rankings. According to
Google it will take 6-8 weeks to see the changes reflected
on your pages.

Other ways to implement the 301 redirect:

1. To redirect ALL files on your domain use this in your
.htaccess file if you are on a unix web server:

redirectMatch 301 ^(.*)$
redirectMatch permanent ^(.*)$

You can also use one of these in your .htaccess file:

redirect 301 /index.html
redirect permanent /index.html
redirectpermanent /index.html

This will redirect “index.html” to another domain using a
301-Moved permanently redirect.

2. If you need to redirect to and you’ve got mod_rewrite enabled on
your server you can 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 ^(.*)$$1 [R=301,L]

Tip: Use your full URL (ie when
obtaining incoming links to your site. Also use your full
URL for the internal linking of your site.

3. If you want to redirect your .htm pages to .php pages
andd you’ve got mod_rewrite enabled on your server you can
put this in your .htaccess file:

RewriteEngine on
RewriteBase /
RewriteRule (.*).htm$ /$1.php

4. If you wish to redirect your .html or .htm pages to
.shtml pages because you are using Server Side Includes
(SSI) add this code to your .htaccess file:

AddType text/html .shtml
AddHandler server-parsed .shtml .html .htm
Options Indexes FollowSymLinks Includes
DirectoryIndex index.shtml index.html

Popular Posts

remove index.php fro

How to remove index.php from url in magento Ans : If you ...

PHP-Java bridge on p

  What is php-java bridge? The php-java bridge is the php ...

Set expiration for y

If you want to set the expiration to your site ...

Warning: Parameter 1

Error: Warning: Parameter 1 to modMainMenuHelper::buildXML() expected to be a ...

domain pointing to e

If you domain uses external MX record and it is ...