views:

106

answers:

2

While randomly browsing my website via Google, I noticed that it was showing up remote redirects as local files. Now this can be both good and bad, but I'm wondering how can I fix this so it doesn't happen?

I'm currently using PHP and header('Location: ... which sends a 302 redirect. Looking over the list of HTTP status codes, I'd take a guess that I should be using 303 redirects to redirect offsite. Is anyone able to help me here, and either confirm/deny this, or tell me what I should be doing instead?

Obviously, due to me not being able to tell Google to reindex my site on command, there's issues with being able to test this myself...

+1  A: 
Note: Many pre-HTTP/1.1 user agents do not understand the 303
status. When interoperability with such clients is a concern, the
302 status code may be used instead, since most user agents react
to a 302 response as described here for 303.

I don't know what pre-HTTP/1.1 user agents there are out there, so... Depending on what you're going for, I'd use either 301 (permanent) or 307 (temporary). 301 will tell Google to behave as if you linked to the redirected site directly.

303 looks like it's intended for use in redirecting after submitting forms, specifically.

edit:

though your question is "What HTTP redirect status should I use to link offsite?" -- how about linking offsite directly? (which I guess doesn't work if you're using a form to do the linking, in which case you would use the 303 status code)

James Cassell
The link goes via a click counter, which then redirects off-site.
Matthew Scharley
+1  A: 

The 303 status code is intended to be used in response of a POST request to redirect to a different resource:

This method exists primarily to allow the output of a POST-activated script to redirect the user agent to a selected resource.

In your case you should use the 301 status code for a permanent redirect:

The requested resource has been assigned a new permanent URI and any future references to this resource SHOULD use one of the returned URIs.

Or you use a temporary redirect (302/307) and tell the search engines not to index that documents.

Gumbo
Is there a way to tell it that it shouldn't index a particular page, but should keep indexing other pages linked to from that page? robots.txt would stop it from indexing it, but it would also stop it accessing the page at all, and hence it wouldn't follow the link.
Matthew Scharley
@Matthew Scharley: Try a `<meta name="robots" content="noindex" />` in the head of the document.
Gumbo