Which HTTP redirect status code is the best for redirect a webpage to the mobile version?
From: www.example.com
To: m.example.com
I would send a 301 while using Vary to specify the request header fields that lead to this server-driven negotiation decision.
So, assuming that the User-Agent header field is used to distinguish whether the request was made by a mobile device, I would use this:
HTTP/1.1 301 Moved Permanently
Vary: User-Agent
Location: http://m.example.com/...
A temporary redirection (302 or 307) should be sufficient for this.
The Google guidelines for smartphone site redirections states-
For this purpose, it does not matter if the server redirects with an HTTP 301 or a 302 status code.
As such, a 302 is probably preferable over 307.
The guidelines suggest that the "vary" header should be part of the 200 response.