PDA

View Full Version : Redirecting your Sites/pages


Paulhem
12-18-2006, 02:29 PM
Dont use meta refresh or javascripts to redirect a page or even a whole site. Google can and will penalise you eventually for this.

Use you htaccess file and create a 301 redirect

Also try to redirect to a site thats been crawled already to beat the google ageing/sandbox trap.


What is 301 redirect?

301 redirect is the best method to preserve 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?

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
errors.

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 http://www.you.com/new.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
location.

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)

http://www.you.com/new.htm (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 ^(.*)$ http://www.domain.com
redirectMatch permanent ^(.*)$ http://www.domain.com

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

redirect 301 /index.html http://www.domain.com/index.html
redirect permanent /index.html http://www.domain.com/index.html
redirectpermanent /index.html http://www.domain.com/index.html

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

2. If you need to redirect http://mysite.com to
http://www.mysite.com 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 ^(.*)$ http://www.example.com/$1 [R=permanent,L]

or this:

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]

Tip: Use your full URL (ie http://www.domain.com) 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

beastor
11-30-2007, 01:48 PM
This is a perfect place for my question.
I will try to draw this well.
say we have www.bob.com/old/ inside this "old" folder, I have 12 other folders each containing 25 html pages.
Now, is there a way to catch calls to every file inside every folder inside "old" and redirect them all to
www.bob.com/new.html

Basically, i did a huge server change and the stuff that was in old got lost. So rather than try to rebuild it, I just wanna catch those se calls and sent them to new.html

Paulhem
12-03-2007, 12:09 AM
Redirect Multiple Pages In Your Site To One Page Using .htaccess

.htaccess Redirection for a Directory:

To redirect an entire directory to a single file on another site: First use a text ediot and create a .htaccess file (that’s the name!). Save it into the folder you are redirecting. Here’s the complete code you need:

RedirectMatch (.*)/ http://www.yoursite.com/destinationdir/destination.html

This will redirect all hits to any file in the directory to the destination file. You may want to use a redirect message in destination.html so visitors will know to update their bookmarks.

Redirect an entire directory file-for-file

To redirect an entire directory file-for-file to another site with the exact same file structure, use the following Redirect command:

Redirect /sourcedir http://www.yoursite.com/destinationdir

beastor
12-03-2007, 02:16 PM
Thanks So Much. :)