Google Answers Logo
View Question
 
Q: redirect webpages ( Answered 5 out of 5 stars,   1 Comment )
Question  
Subject: redirect webpages
Category: Computers > Internet
Asked by: doctordoris-ga
List Price: $20.00
Posted: 02 Dec 2003 14:25 PST
Expires: 01 Jan 2004 14:25 PST
Question ID: 282772
I wanted to know how to permanently redirect webpages to a new site. I
need exact step by step technical instructions as to how to change the
coding in html file, using 301 permanent redirect. I wanted my new
pages to stay in the search engines.Thanks very much!
Answer  
Subject: Re: redirect webpages
Answered By: larre-ga on 02 Dec 2003 18:12 PST
Rated:5 out of 5 stars
 
Thanks for asking!

For a search engine friendly Permanent Redirect on an Apache server,
you'll need to create or modify the .htaccess file. Here's how:


Create and/or edit the .htaccess file
----------------------------------------------------------------------

.htaccess is actually a plain ascii text file. It can be created in
any text editor (Notepad, BBEdit, etc.) by simply opening a new, blank
file. If your site already uses an .htaccess file, be sure you're
working with the current version. You might want to download it from
your site via FTP, just to be on the safe side. Open the file for
editing with your usual text editor.

If you use Frontpage, this file will already be in use. You -must-
download the current version first, and add the redirects to the
beginning of the file.


Add the Permanent Redirect command(s)
----------------------------------------------------------------------

The Permanent Redirect command is written as shown in these examples:

Redirect permanent /oldpage1.html http://www.new.com/newpage.html
Redirect permanent /oldpage2.html http://www.new.com/sub/newpage.html


You may also redirect entire directories (subfolders) using:

Redirect permanent /olddirectory http://www.newcom/newdirectory

You'll need to substitute your actual site, file and directory names
for those I've used in these examples.


Save the File
----------------------------------------------------------------------

Save the .htaccess file. Some Windows text editors don't care for this
type of file name (no name, plus an eight character file extension),
and might try to add a .txt extension to the name when the file is
saved. If that should occur, just rename the file correctly in the
Windows display of that folder, or use your FTP program's Rename File
command to correct it either on your system or on your server.


Upload
----------------------------------------------------------------------

Using your uploader or FTP program, upload the .htaccess file to your
web server, to the old site's root directory (same directory/folder as
your homepage).


Here are also a couple of resource sites that explain use of the
.htaccess file in detail, and offer simple tutorials.

Fun With .HTACCESS
http://www.hostingmanual.net/other/htfun.shtml

.htaccess Tutorial - Redirect Pages
http://www.clockwatchers.com/htaccess_redirect.html


Redirection on IIS and WIN Servers
----------------------------------------------------------------------

Redirection (For IIS Servers)
http://www.xoc.net/works/tips/domain.asp

ASP Code for 301 Redirects (Msg #3)
http://www.webmasterworld.com/forum23/1167.htm



Google Search Terms
----------------------------------------------------------------------

301 redirect apache OR iis
redirect permanent .htaccess tutorial


If you have questions about this information or links, please, feel free to ask.

---larre

Request for Answer Clarification by doctordoris-ga on 03 Dec 2003 07:58 PST
Thanks very much, Larre, for your detailed explanation. As someone who
is beginning to learn about technical elements of webmastering, I
would need further explanations/instructions as to how to do the
things you suggested. For example, I know how to edit a webpage's
content or modify the html coding using Netscape composer, and I know
how to upload a file to my site via FTP.

Now, when you say "If your site already uses an .htaccess file, be
sure you're working with the current version". 1)What do you mean?
2)How do I know what version or wheather or not itis the .htaccess
file my site is using? Is there a key I should press or command to
use? 3)I can ceratinly download my site using FTP and save it on my
pc, but then what? 4)Do I just open the downloaded file in either
Microsoft Word (my usual editor)or Nescape Composer (I use it for
webpage editing) to edit? 5)Then, my next question is: Do I add the
permanent redirect comments you listed right on top of my original
text in my webpage? I thought I needed to go in html coding and change
the codes. 6)It seems, from your answer, that I only would need to
download my webpage and add these commands to the top part of my page
content (using a text editor), save it afterwards and upload it back
to the server. Is this right?

Please answer all of the six questions listed above, because I needed
to know exact step by step instructions to achieve redirecting
webpages (I guess what I need is something like step 1: do this; step
two: do that). Thanks again!

Clarification of Answer by larre-ga on 03 Dec 2003 10:04 PST
Good morning (from the US Left Coast). I'll be happy to work with you
to make this operation as painless as possible. Sometimes it's
difficult to tell from initial question exactly what level of
technical or non-technical explanations are "just right" -- now that
we're talking, I'm sure we can manage it.

Your questions: 

#1 - Current Version of the .htaccess file

Some webpage creation software or web hosts automatically insert an
.htaccess file. It wasn't clear from your original questions whether
or not you were familiar with this file, and might have included it at
some previous time. I just wanted to be sure that we were working with
the most current version if the file is already in use.


#2 - How do I know the version of the .htaccess file

I  made the assumption that you might be using an FTP program (WS FTP
or the like) or a specialty HTML editor (such as Frontpage,
Dreamweaver, CoffeeCup, etc.) to transfer software between your
computer system and your web host, and would be familiar with the
actions required to download a specific file, in this case, the
.htaccess file.

You'd know which version by downloading the file, and opening it with
your text editor -if- the file already exists. Actually, I considered
it to be less likely that you'd already have this file in use, but
wanted to cover the contingency, just in case. Don't worry about
"which buttons" yet.


#3 - Do I download my entire site?

You "could" download the entire site or the individual .htaccess file,
but based on what you've told me in this Clarification it's not
necessary. We'll start from scratch.


#4 and #5 - Do I just "open the file" and add to it?

Let's use Notepad rather than Word or NS Composer. Word inserts extra
characters into its text documents. We need a plain text editor for
this process. In case you're not familiar with this program, you'll
find Notepad by pressing the Start icon in the bottom left corner of
your screen, then mousing over Programs, then Accessories, and
clicking on Notepad.

We're going to start from scratch, so there's no need to open a file.
Just open the Notepad program. It's clear that you don't have the file
yet, and we will need to create it from scratch.

#6 - Do I just open the webpage, etc.?

No. This isn't a webpage. It's a special file that we'll create with
the following steps.



Open Notepad to a blank page. 

Type the Permanent Redirect command(s):

Redirect permanent /oldpage1.html http://www.new.com/newpage1.html


-- Be sure you include the "/" at the beginning of the older page
   name, and space as I've demonstrated. 

-- Each page to redirect should have its very own command line.
   One page to a line. (You might need to drag the left and/or 
   right edges of the Notebook program window so that it is wide
   enough to accommodate the width of these command lines.) 

-- Use the full address (full URL) of the new web page in the
   command line. 

-- You'll need to substitute your actual current page names for 
   oldpage1.html I've used in the example. 

-- You'll need to substitute your actual new site name for the 
   www.new.com I've used in the example. 

-- You'll need to substitute the actual new page names for 
   newpage1.html that I've used in the example. 


Once you've listed all the webpages to be Redirected, Save the file in
your website folder.

Name the file .htaccess

Notepad will try append .txt to the file name, which is okay. We'll
correct it in the next step or two.



Using Windows (i.e. open My Computer), navigate to the folder that
contains your website HTML pages and the newly created .htaccess.txt
file. Right click on the .htaccess.txt file and select Rename File
from the menu. In the popup textbox, "erase" the .txt from the
filename. Answer yes to any questions.

Using your FTP program, upload the .htaccess file to the "Home"
directory of the "old" website, i.e. the same directory as your
homepage.

Test the process by requesting one of the old webpages. If the file
has been created and installed properly, you should instead be sent to
the new webpage location.


I'm going to suggest that you test the whole process by first creating
and saving the .htaccess file with only a single page redirect in it.
Once you're sure it's correct, you can add any/all the other Redirect
lines you need.

Upload and test the file to make sure it works properly. You won't
need to download the test version. Just work with the document in
Notepad and upload as many times as necessary using your FTP program.
Answer Y if you're asked to Overwrite during the upload operation.



If anything is unclear, I'll be happy to rephrase or give additional
directions. It may simply be a case of us each using different names
for the same doohickey or whatchamacallit. :-)

---l

Request for Answer Clarification by doctordoris-ga on 03 Dec 2003 18:17 PST
Hi again, Larre,

Sorry for the delay. I had to read your clarifications a few times and
test-run it as you suggested, making sure that I know exactly what you
said in the message in the practical sense.

First of all, I?d like to thank you for your understanding and
patience in helping me out. It?s so kind of you to have offered step
by step instructions and advice on things to watch for during the
process. You made it seem simple for me.

OK, I followed your instructions line by line and got the part when I
needed to save the .htacces text file. Although I used notepad as you
indicated, I didn't have to rename the file, because after I entered
".htaccess" in the box for file name, it was saved as named. So, when
I tried to retrieve this file, I could see its name was ".htaccess"
and it was a text document as said in its property. Then, I went to
AOL where I have my home page and tried to upload this text file using
FTP. Well, everything was OK until the last step, when I clicked Yes
to uploading text document. Here is the error prompt I got at this
point:

File or directory names on this server must contain only alphanumerics
(?A-Z? upper or lower case, or the digits ?0-9?and the characters
underscore (?_?) hyphen (?-?) or period (?.?)-and must not begin with
either a hyphen or a period. No spaces or other special characters are
now permitted. Permission denied(file deny)

So, I failed the test. I wonder if there is anything that I did wrong?
Please advise. I feel that I am almost there. Thank you very much
indeed!

D.

Clarification of Answer by larre-ga on 03 Dec 2003 20:41 PST
You've done perfectly! Nothing wrong at all. It's my mistake. AOL
doesn't support the .htaccess file.

You asked for exactly the right item in the first place ... the
HTML/Javascript code that's needed for an individual page redirect.
This method has almost fallen by the wayside, except for AOL, and I
neglected to consider that possibility. I'm very sorry to have caused
you extra work and delay in getting this accomplished.

Here's the code you'll need. It's a combination of META refresh plus
Javascript, which just means that it will redirect as many browsers as
is possible with this method. The search engines don't like it as
well, which is why it was replaced with the .htaccess method, however,
the Googlebot should follow the link to the new site and crawl it. You
may temporarily dip in the rankings, but should regain position as you
notify those who've linked to you to update their links with the new
URL.

You'll use this code as is (with the appropriate substitutions as
listed below) -AS THE REPLACEMENT- for each of your current pages.


---------------------CUT-N-PASTE-BELOW--------------------------------


<html>
<head>

<title>Old Page Title - Permanent Redirect</title>
<meta http-equiv="Refresh" content="10;URL=http://www.newsitenewpage.html">

<script language="JavaScript"><!--
function redirect () { setTimeout("go_fish()",10000); }
function go_fish ()   { window.location.href = "http://www.newsitenewpage.html"; }
//--></script>

</head>

<body onLoad="redirect()">

<h1>We've Moved!</h1>

<br><br>
<p>The new location of "Page Title" is: http://www.newsitenewpage.html</p>
<p>Please update your bookmarks.</p>
<p>This page will automatically redirect you in 10 seconds.</p>
<p>If this does not work for any reason, use the link below:</p>
<p><a href="www.newsitenewpage.html">http://www.newsitenewpage.html</a>

</body>
</html>

---------------------CUT-N-PASTE-ABOVE--------------------------------

SUBSTITUTIONS

Old Page Title - The title of the 'old' page
"Page Title" - The title of the 'old' page (no quotes)
http://www.newsitenewpage.html  -  your new site page URL


Once again, I apologize for making this changeover more difficult than
it needed to be. I'll be happy to answer questions, if anything is
unclear.

---l

Request for Answer Clarification by doctordoris-ga on 03 Dec 2003 22:30 PST
Hi, Larre,

Thanks for putting up with my confusing situation. I should have told
you that I use AOL as my home site (I didn't know this would make a
difference).

Anyway, this time I followed your instructions precisely and
cut-n-paste the part you wrote, replacing the "old Page Title" with
the actual one and changed the part you used as an example into my new
page URL. Wow, it worked. I did check the new page using the new
address and that page opens with the wording I wanted.

Now, the only unexpectedness was that in my new webpage (old content),
the first half of the page was original just text (in paragraphs), but
now in the new webpage, it appears in the way that all the lines in
the first half of the page are underlined and the background color of
this top half portion of the page was missing. So, the bottom half of
this page is normal (text without underlining and with background
colors). But I did not change anything more than what you had told me
in the coding. So, I don't know how to make the appearance of the new
page look exactly like the old one now.

I didn't expect I would encounter more problems and hopefully this is
the last time I have to bug you for a solution. Thanks so much for
your help!

D.

Clarification of Answer by larre-ga on 03 Dec 2003 22:48 PST
The new webpages shouldn't have changed in any way. It sounds as if a
link <a href> has inadvertently been left "open", but I wouldn't be
able to tell without seeing the code.

In order to do that, you'd either have to post the HTML code here, or
post the webpage URL for me to take a look. You might (or might not)
have privacy concerns.

The alternative is, perhaps, to use an HTML Syntax Checker. 

Online HTML Syntax Checker
http://www.htmlvalidator.com/lite/onlineval.php

We'll getcha there one way or another. :)

---l

Request for Answer Clarification by doctordoris-ga on 04 Dec 2003 10:13 PST
Hi again, Larre,

Thanks for your explanations. I thought about it and did a few test. I
think I should just leave the cut-n-paste part of the coding in the
new file and delete the rest of the codes (the content of the old
page), so that when people open the old page, they only see the
re-directing message. This way, I can simply upload the untouched old
page onto my new website, which people will read after 10 seconds'
waiting in the old page. So, other settings won't be changed by
mistake.

I succeeded! So happy!! Now, I realized that I have to do this to
every webpages (about 10)I have (by adding the new codes to the html
file and delete the rest) although they are all originally with AOL.
But that's OK, it may be even faster than doing it in other ways.

Thanks so much and I have learned so much from you!

D.

Clarification of Answer by larre-ga on 04 Dec 2003 11:01 PST
It's been a pleasure to work with you. Thank you for the 5 star rating.

---1
doctordoris-ga rated this answer:5 out of 5 stars

Comments  
Subject: Re: redirect webpages
From: bgbuck7-ga on 02 Dec 2003 14:44 PST
 
It is not HTML code that you need, but in your .htaccess file (if you
don't have one, make one) in your root directory, you need to add 
this line:
redirect permanent / http://www.newsite.com/

assuming your domain name is http://www.mydomain.com/ and your
redirect is http://www.newsite.com/

You should have a file located at: http://www.mydomain.com/.htaccess
that contains the line: redirect permanent / http://www.newsite.com/

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy