Your options are limited because you are relying on the server operator to send the correct HTTP status codes and this is not guaranteed to happen. Many websites will return a 200 OK response with their custom 404 Not Found page, for example, and this is just wrong.
The simplest way to test is to use curl's -I option which returns the header only. curl -I http://www.example.com
will display a much shorter response beginning with the HTTP status code. If the server operator has correctly configured things, you will see if a 3XX Redirect response is returned.
Varon's answer here describes why this is happening for Google's website which is what you used as an example in your question. My answer here is a more general response that you can attempt to use for any site, but again you are relying on the server giving the correct response which you just can't depend on.