Question

Currently my web site shows the same data if people go to domain.com or www.domain.com.

I would like to set up a redirect so all requests to domain.com will get sent onto www.domain.com. So a user who goes to domain.com will get redirected to www.domain.com. Just like what happens if you go to http://amazon.com/?a=b

I don't want to lose or corrupt any GET or POST data that is sent in the domain.com request.

What is the best way to do this? Should I use a 301 redirect? Will this cause the user's browser to re-send GET/POST data to the www.domain.com URL?

[EDIT] Ok, Zaagmans says redirecting POST transparently to the user is not possible. So lets ignore POST for the moment. How should I redirect with just query string data?

Was it helpful?

Solution

The Redirecting Post Requests article explains this in detail.
A (possible) downside of the proposed 307 redirect is the fact that the browser will alert the user and present an option to proceed or to cancel the request.

OTHER TIPS

Yes. For GETs, you'll need to use a 301, and the browser will need to re-request it. If your GETs are idempotent (and they should be), this won't be a problem. Search engines respect 301s in ways that they don't respect other 30x codes.

I don't know which web server you're using, but there are usually URL rewrite/redirect modules that will handle a lot of this for you.

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