Question

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...

Was it helpful?

Solution

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.

OTHER TIPS

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)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top