redirect 301

G

Gpr0496

Exactly how do you get a 301 redirect to work....i have researched for the
last few hours, and am having no luck. The code I found for a windows based
server is
<%
Response.Status = "301 Moved Permanently"
Response.AddHeader "Location", "http://www.newdomain.com/page.html"
Response.End
%>
or
<%
If (InStr(Request.ServerVariables("QUERY_STRING"), "oldpage.htm") <> 0) Then
Response.Status = "301 Moved Permanently"
Response.AddHeader "Location", "newpage.htm"
Response.End
ElseIf (InStr(Request.ServerVariables("QUERY_STRING"), "oldpage2.htm") <> 0)
Then
Response.Status = "301 Moved Permanently"
Response.AddHeader "Location", "newpage2.htm"
Response.End
Else
Response.Status = "404 Not Found"
End If
%>

Which code is correct and what do I do with it? Do I add the script on the
page that I want to redirect (if so, exactly where do I place it, or do I
create a new page?. If I create a new page, what do I save it as? All of my
files are htm. Help!!!!! Thanks again.....
 
D

David Berry

If you're trying to get a custom error message to appear rather than the
default error message then this needs to be set up on the server. If your
host allows it, you'd create a custom error page using your ASP code (ex:
301.asp) and then the host would point the error to that page.
 
J

Jon Spivey

Hi,
Unless you set your server to parse .htm pages as asp this code will not
work. The code itself is fine - the issue is that an .htm page cannot
usually process asp code.

If you're on some form of unix server you may be able to do what you want
with mod rewrite - google this phrase for info.
 

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

Similar Threads

301 redirect 3
301 Redirects 1
301 redirect 2
OFF-TOPIC how to do a 301 Redirect? 3
301 redirect 6
Auto Redirect 3
How can I redirect to a URL? 0
Problem with using Login.inc and Frames Pages 1

Top