301 redirect

G

Gpr0496

I can't figure out how to redirect my old page to my new page using a 301
redirect page. I am using a windows based server (asp). I have written all
pages in html code. What code should I use to redirect the page and where do
I place the code...in the html code of the old page?...and what do I save the
page as...html or asp? I will be changing several page names. I don't want
to use the REFRESH in my tags to redirect. Help!!!!! Thank you.....
 
T

Trevor L.

Gpr0496 said:
I can't figure out how to redirect my old page to my new page using a
301 redirect page. I am using a windows based server (asp). I have
written all pages in html code. What code should I use to redirect
the page and where do I place the code...in the html code of the old
page?...and what do I save the page as...html or asp? I will be
changing several page names. I don't want to use the REFRESH in my
tags to redirect. Help!!!!! Thank you.....

See my reply on microsoft.public.frontpage.programming

BTW, since I have never used a 301 Redirect, what does it do differently and
what are its advantages ?
 
T

Trevor L.

Trevor said:
BTW, since I have never used a 301 Redirect, what does it do
differently and what are its advantages ?

With a bit of Googling, I found some answers.

This code will redirect to new.asp:
<% Response.Status="301 Moved Permanently"
Response.AddHeader "Location","http://new.com/new/new.asp"
%>

or this code will redirect to new.html:
<% Response.Status="301 Moved Permanently"
Response.AddHeader "Location","http://new.com/new/new.html"
%>

But the file must be saved as ASP, e.g. index.asp

As to the questions:
1. What does it do differently ?
2. What are its advantages ?

My off-the-top responses are:
1. Not much - it works as well as a JS redirect.
2. Not many. In fact, are there any ?

Does anyone else have any contrary opinions ?
 
R

Ronx

A 301 redirect tells search engines that the page has been permanently
moved to a new location.
Adding this code to a .htm page is useless, since the code will not be
rendered by the server, and changing the page extension to .asp will
give the .htm page a 404 error - and no-one will look for the .asp page
anyway.

The code should (probably) be added to a custom 404 error page (with
suitable logic to determine which page has been moved where or if it is
a genuine 404), which needs to be set up on the server, and the original
..htm removed.
--
Ron Symonds - Microsoft MVP (FrontPage)
Reply only to group - emails will be deleted unread.
FrontPage Support: http://www.frontpagemvps.com/
http://www.rxs-enterprises.org/fp



Trevor said:
BTW, since I have never used a 301 Redirect, what does it do
differently and what are its advantages ?

With a bit of Googling, I found some answers.

This code will redirect to new.asp:
<% Response.Status="301 Moved Permanently"
Response.AddHeader "Location","http://new.com/new/new.asp"
%>

or this code will redirect to new.html:
<% Response.Status="301 Moved Permanently"
Response.AddHeader "Location","http://new.com/new/new.html"
%>

But the file must be saved as ASP, e.g. index.asp

As to the questions:
1. What does it do differently ?
2. What are its advantages ?

My off-the-top responses are:
1. Not much - it works as well as a JS redirect.
2. Not many. In fact, are there any ?

Does anyone else have any contrary opinions ?

--
Cheers,
Trevor L.
[ Microsoft MVP - FrontPage ]
MVPS Website: http://trevorl.mvps.org/
 
G

Gpr0496

Hi Ron,
Thanks for your input...I am trying to change some page names for SEO
reasons and read that if the pages are already indexed, it is a good idea to
use a 301 redirect so while the new page is being indexed, the old page will
still be found and will redirect the user to the new page. (and also keep the
page's rank) I have saved all of my pages as htm...I can redirect the old
page to my home page via my host's custom 404, but I am looking for a way to
redirect each individual old page to their corresponding new page instead of
redirecting them to just the home page. I tried my host's help page which
suggested this code:

PHP Code - save this as oldpagename.php

<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.newdomain.com/newpage.html");
exit();
?>
ASP Code - save this as oldpagename.asp

<%@ Language=VBScript %>
<%
Response.Status="301 Moved Permanently" Response.AddHeader "Location", "
http://www.new-url.com"
<%@ Language=VBScript %>
<%
Response.Status="301 Moved Permanently" Response.AddHeader "Location", "
http://www.new-url.com"
I tried asp, but no luck...not sure exactly where to place the code. I
tried it on one of my practice websites and saved the old page as asp, then
renamed a new page and saved it as htm. I get and error page. (I guess
that's why you said the asp page will not be rendered by the server??)
what about php??
Thanks for your help yet again!!
Ronx said:
A 301 redirect tells search engines that the page has been permanently
moved to a new location.
Adding this code to a .htm page is useless, since the code will not be
rendered by the server, and changing the page extension to .asp will
give the .htm page a 404 error - and no-one will look for the .asp page
anyway.

The code should (probably) be added to a custom 404 error page (with
suitable logic to determine which page has been moved where or if it is
a genuine 404), which needs to be set up on the server, and the original
..htm removed.
--
Ron Symonds - Microsoft MVP (FrontPage)
Reply only to group - emails will be deleted unread.
FrontPage Support: http://www.frontpagemvps.com/
http://www.rxs-enterprises.org/fp



Trevor said:
BTW, since I have never used a 301 Redirect, what does it do
differently and what are its advantages ?

With a bit of Googling, I found some answers.

This code will redirect to new.asp:
<% Response.Status="301 Moved Permanently"
Response.AddHeader "Location","http://new.com/new/new.asp"
%>

or this code will redirect to new.html:
<% Response.Status="301 Moved Permanently"
Response.AddHeader "Location","http://new.com/new/new.html"
%>

But the file must be saved as ASP, e.g. index.asp

As to the questions:
1. What does it do differently ?
2. What are its advantages ?

My off-the-top responses are:
1. Not much - it works as well as a JS redirect.
2. Not many. In fact, are there any ?

Does anyone else have any contrary opinions ?

--
Cheers,
Trevor L.
[ Microsoft MVP - FrontPage ]
MVPS Website: http://trevorl.mvps.org/
 
R

Ronx

Same applies to PHP - the pagename will have to be changed to a .php
extension.

On my site - using IIS on Windows 2003 - I have a custom 404 error page
which uses ASP to decide whether the page concerned has been relocated,
or is a genuine error.
If relocated, the asp relocation script is used, if an error the 404 is
displayed.

The server creates a variable which can be parsed by the asp code:

Example:
<%
qstr = request.serverVariables("QUERY_STRING")
qstr = lcase(qstr)
errpge = mid(qstr,5)
'the querystring is in the form 404;http://example.com/path/pagename.htm
if inStr(errpge,"pagename.htm") > 0 then
response.status="301 Moved Permanently"
response.addheader "Location", "http://example.com/newpage.htm"
end if
%>

In your case, check how the server transfers an error to your custom
404, and you will have to write a new 404 page with an .asp extension
and have the server use that new page - your SEO will suffer if you
rename your home page.
--
Ron Symonds - Microsoft MVP (FrontPage)
Reply only to group - emails will be deleted unread.
FrontPage Support: http://www.frontpagemvps.com/
http://www.rxs-enterprises.org/fp



Hi Ron,
Thanks for your input...I am trying to change some page names for SEO
reasons and read that if the pages are already indexed, it is a good idea to
use a 301 redirect so while the new page is being indexed, the old page will
still be found and will redirect the user to the new page. (and also keep the
page's rank) I have saved all of my pages as htm...I can redirect the old
page to my home page via my host's custom 404, but I am looking for a way to
redirect each individual old page to their corresponding new page instead of
redirecting them to just the home page. I tried my host's help page which
suggested this code:

PHP Code - save this as oldpagename.php

<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.newdomain.com/newpage.html");
exit();
?>
ASP Code - save this as oldpagename.asp

<%@ Language=VBScript %>
<%
Response.Status="301 Moved Permanently" Response.AddHeader "Location", "
http://www.new-url.com"
<%@ Language=VBScript %>
<%
Response.Status="301 Moved Permanently" Response.AddHeader "Location", "
http://www.new-url.com"
I tried asp, but no luck...not sure exactly where to place the code. I
tried it on one of my practice websites and saved the old page as asp, then
renamed a new page and saved it as htm. I get and error page. (I guess
that's why you said the asp page will not be rendered by the server??)
what about php??
Thanks for your help yet again!!
Ronx said:
A 301 redirect tells search engines that the page has been permanently
moved to a new location.
Adding this code to a .htm page is useless, since the code will not be
rendered by the server, and changing the page extension to .asp will
give the .htm page a 404 error - and no-one will look for the .asp page
anyway.

The code should (probably) be added to a custom 404 error page (with
suitable logic to determine which page has been moved where or if it is
a genuine 404), which needs to be set up on the server, and the original
..htm removed.
--
Ron Symonds - Microsoft MVP (FrontPage)
Reply only to group - emails will be deleted unread.
FrontPage Support: http://www.frontpagemvps.com/
http://www.rxs-enterprises.org/fp



Trevor L. wrote:
BTW, since I have never used a 301 Redirect, what does it do
differently and what are its advantages ?

With a bit of Googling, I found some answers.

This code will redirect to new.asp:
<% Response.Status="301 Moved Permanently"
Response.AddHeader "Location","http://new.com/new/new.asp"
%>

or this code will redirect to new.html:
<% Response.Status="301 Moved Permanently"
Response.AddHeader "Location","http://new.com/new/new.html"
%>

But the file must be saved as ASP, e.g. index.asp

As to the questions:
1. What does it do differently ?
2. What are its advantages ?

My off-the-top responses are:
1. Not much - it works as well as a JS redirect.
2. Not many. In fact, are there any ?

Does anyone else have any contrary opinions ?

--
Cheers,
Trevor L.
[ Microsoft MVP - FrontPage ]
MVPS Website: http://trevorl.mvps.org/
 
D

David Berry

Just a note here, if you want to use an ASP page for the Custom Error then
the "type" in IIS needs to be set to URL rather than File when you set up
the error page (under the properties for the web site).


Ronx said:
Same applies to PHP - the pagename will have to be changed to a .php
extension.

On my site - using IIS on Windows 2003 - I have a custom 404 error page
which uses ASP to decide whether the page concerned has been relocated, or
is a genuine error.
If relocated, the asp relocation script is used, if an error the 404 is
displayed.

The server creates a variable which can be parsed by the asp code:

Example:
<%
qstr = request.serverVariables("QUERY_STRING")
qstr = lcase(qstr)
errpge = mid(qstr,5)
'the querystring is in the form 404;http://example.com/path/pagename.htm
if inStr(errpge,"pagename.htm") > 0 then
response.status="301 Moved Permanently"
response.addheader "Location", "http://example.com/newpage.htm"
end if
%>

In your case, check how the server transfers an error to your custom 404,
and you will have to write a new 404 page with an .asp extension and have
the server use that new page - your SEO will suffer if you rename your
home page.
--
Ron Symonds - Microsoft MVP (FrontPage)
Reply only to group - emails will be deleted unread.
FrontPage Support: http://www.frontpagemvps.com/
http://www.rxs-enterprises.org/fp



Hi Ron,
Thanks for your input...I am trying to change some page names for SEO
reasons and read that if the pages are already indexed, it is a good idea
to
use a 301 redirect so while the new page is being indexed, the old page
will
still be found and will redirect the user to the new page. (and also keep
the
page's rank) I have saved all of my pages as htm...I can redirect the
old
page to my home page via my host's custom 404, but I am looking for a way
to
redirect each individual old page to their corresponding new page instead
of
redirecting them to just the home page. I tried my host's help page
which
suggested this code:

PHP Code - save this as oldpagename.php

<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.newdomain.com/newpage.html");
exit();
?>
ASP Code - save this as oldpagename.asp

<%@ Language=VBScript %>
<%
Response.Status="301 Moved Permanently" Response.AddHeader "Location", "
http://www.new-url.com"
<%@ Language=VBScript %>
<%
Response.Status="301 Moved Permanently" Response.AddHeader "Location", "
http://www.new-url.com"
I tried asp, but no luck...not sure exactly where to place the code. I
tried it on one of my practice websites and saved the old page as asp,
then
renamed a new page and saved it as htm. I get and error page. (I guess
that's why you said the asp page will not be rendered by the server??)
what about php??
Thanks for your help yet again!!
Ronx said:
A 301 redirect tells search engines that the page has been permanently
moved to a new location.
Adding this code to a .htm page is useless, since the code will not be
rendered by the server, and changing the page extension to .asp will
give the .htm page a 404 error - and no-one will look for the .asp page
anyway.

The code should (probably) be added to a custom 404 error page (with
suitable logic to determine which page has been moved where or if it is
a genuine 404), which needs to be set up on the server, and the
original
..htm removed.
--
Ron Symonds - Microsoft MVP (FrontPage)
Reply only to group - emails will be deleted unread.
FrontPage Support: http://www.frontpagemvps.com/
http://www.rxs-enterprises.org/fp




Trevor L. wrote:
BTW, since I have never used a 301 Redirect, what does it do
differently and what are its advantages ?

With a bit of Googling, I found some answers.

This code will redirect to new.asp:
<% Response.Status="301 Moved Permanently"
Response.AddHeader "Location","http://new.com/new/new.asp"
%>

or this code will redirect to new.html:
<% Response.Status="301 Moved Permanently"
Response.AddHeader "Location","http://new.com/new/new.html"
%>

But the file must be saved as ASP, e.g. index.asp

As to the questions:
1. What does it do differently ?
2. What are its advantages ?

My off-the-top responses are:
1. Not much - it works as well as a JS redirect.
2. Not many. In fact, are there any ?

Does anyone else have any contrary opinions ?

--
Cheers,
Trevor L.
[ Microsoft MVP - FrontPage ]
MVPS Website: http://trevorl.mvps.org/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top