Forum Moderators: open

Message Too Old, No Replies

Help with 301 redirects

         

Lightguy1

2:33 pm on May 9, 2008 (gmt 0)

10+ Year Member



Google is telling me my redirects are "empty" and therefore not followed. This is how I am doing my redirects below:

IF !EMPTY(pcnewitemno)
oHeader = CREATE("wwHTTPHeader",Response)
oHeader.setprotocol([HTTP/1.1 301 object permanently moved])
oHeader.CompleteHeader()
Response.WriteLn([<html><meta http-equiv="refresh"content="0;url=http://www.mysite.biz/moreinfo.int?itemno=]+pcnewitemno+[ ></html>])

Tedster told me this, "Note that the server header is not the same as the <head> section of the page's source code - they are two different critters altogether.

This means that writing a few lines containing a meta refresh into the page's <head> section is not the same as returning the new "Location:" in the server header. Because there's a 301 http status in the server header, your server will never give googlebot the original url's content - and that's where your script is writing the lines that contain the meta refresh."

So how would i send location so it gets redirected to that?

Thanks

marcel

1:44 pm on May 11, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Something like this?

<%
Response.Status="301 Moved Permanently"
Response.AddHeader "Location", "/MyNewPage.asp"
%>

Lightguy1

3:43 pm on May 13, 2008 (gmt 0)

10+ Year Member



Would I want to incorporate that between the denominators on Response.WriteLn or do I remove that since I am not writing anything at all? I am confused on this and I need to let my programmer know, sorta playing the middleman.

Thanks!

marcel

6:47 am on May 18, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That's all the code you need in your file, it will redirect to the specified page.

Lightguy1

2:31 pm on May 19, 2008 (gmt 0)

10+ Year Member



When I incorporate it it gives me a verb syntax error

pageoneresults

2:41 pm on May 19, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If you are doing 301 redirects at the "page level" and are using Classic ASP, this code would go above all other code on the page, before the opening <html> element and/or DOCTYPE if one is present.

<%@ Language=VBScript %>
<%
Response.Status="301 Moved Permanently"
Response.AddHeader "Location", "/new-page.asp"
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>

That would be the "Poor Man's" solution but it works just fine. If you've got a large volume of pages, it may not be the best solution.

And, if you are on a .NET platform, you can use this at the "page level"...

<script runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location","/new-page.asp");
}
</script>

I've not seen the type of code example you provided above. Are you doing redirects through a .NET routine?

If you have a large volume of redirects and/or need to maintain them regularly, I'd recommend a rewrite solution like ISAPI_Rewrite to handle this for you. It can become quite tedious trying to do this using the "page level" solution and we've found the .NET rewrite facilities to be not as robust as we need them to be.

Lightguy1

9:19 pm on May 20, 2008 (gmt 0)

10+ Year Member



That code was from my web server. I use web connect along with IIS.