Forum Moderators: coopster & phranque

Message Too Old, No Replies

Server side redirect

Is it ok to use response.redirect?

         

charliek

10:00 am on Jan 22, 2002 (gmt 0)

10+ Year Member



Hi,
I've been doing some research on redirects and which seem to be the most search engine friendly. I'm steering clear of meta refresh and even js redirects don't always get the thumbs up on these forums. So our developer said to use "response.redirect=the URL" for a server side redirect, as it is an asp site. Does anyone know whether this is the best solution for search engines or what exactly happens on the server when the spider comes crawling and gets this?

Basically we need to use a redirect as we are changing our website's url, not recommended I know but out of our hands. Just want to hang on to as much se traffic as possible. Hope I'm posting in the right forum, and thanks for any help.

justa

10:02 am on Jan 22, 2002 (gmt 0)

10+ Year Member



Excuse my ignorance, but why are you staying away from the meta refresh tag?

Xoc

10:11 am on Jan 22, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Response.Redirect sends a 302 error down to the browser, along with the new URL, which then redirects to the new page. Search engines generally follow those. However, you are generally better with search engines if you give a 301 Moved Permanently error. Engines should replace the old page with the new without hurting your rankings, although it will take a while. You can do that with code like this (where strNew is the URL you want to redirect to):

Response.Status = "301 Moved Permanently"
Call Response.AddHeader("Location", strNew)
Call Response.Write("<html><head><title>Object moved</title></head>")
Call Response.Write("<body><h1>Object Moved</h1>")
Call Response.Write("This object may be found at <a href=""" _
& strNew & """>" & strNew & "</a>.")
Call Response.Write("</body></html>")
Call Response.End

charliek

11:58 am on Jan 22, 2002 (gmt 0)

10+ Year Member



Thanks very much for that code - it works great. Just to check, does the 301 error mean that the search engine will drop this page from its database, gradually phasing out the old site?

To answer the previous question, meta refreshes are not search engine friendly and sites which use them can be penalized heavily. The reason is that search engines don't like when users see content different to what they see. Obviously this technique would and has been abused, in order to gain high rankings.

Thanks again!

Xoc

6:45 pm on Jan 22, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



A 302 error is a "Found". That means that it is just supposed to redirect to the new page, but not change anything. A 301 error is "Moved Permanently". Search engines and browser bookmarks are supposed to get updated to the new site with a 301. Whether they do it or not is an implementation detail.

From [ietf.org ] (which is the definitive reference on the HTTP protocol):

10.3.2 301 Moved Permanently

The requested resource has been assigned a new permanent URI and any
future references to this resource SHOULD use one of the returned
URIs. Clients with link editing capabilities ought to automatically
re-link references to the Request-URI to one or more of the new
references returned by the server, where possible. This response is
cacheable unless indicated otherwise.

The new permanent URI SHOULD be given by the Location field in the
response. Unless the request method was HEAD, the entity of the
response SHOULD contain a short hypertext note with a hyperlink to
the new URI(s).

If the 301 status code is received in response to a request other
than GET or HEAD, the user agent MUST NOT automatically redirect the
request unless it can be confirmed by the user, since this might
change the conditions under which the request was issued.

Note: When automatically redirecting a POST request after
receiving a 301 status code, some existing HTTP/1.0 user agents
will erroneously change it into a GET request.

10.3.3 302 Found

The requested resource resides temporarily under a different URI.
Since the redirection might be altered on occasion, the client SHOULD
continue to use the Request-URI for future requests. This response
is only cacheable if indicated by a Cache-Control or Expires header
field.

The temporary URI SHOULD be given by the Location field in the
response. Unless the request method was HEAD, the entity of the
response SHOULD contain a short hypertext note with a hyperlink to
the new URI(s).

If the 302 status code is received in response to a request other
than GET or HEAD, the user agent MUST NOT automatically redirect the
request unless it can be confirmed by the user, since this might
change the conditions under which the request was issued.

Note: RFC 1945 and RFC 2068 specify that the client is not allowed
to change the method on the redirected request. However, most
existing user agent implementations treat 302 as if it were a 303
response, performing a GET on the Location field-value regardless
of the original request method. The status codes 303 and 307 have
been added for servers that wish to make unambiguously clear which
kind of reaction is expected of the client.