Redirect No Host to WWW Host

Here is the code required to redirect no host to a www host. PHP and ASP versions of the code are included.

PHP

ASP
<% if Request.ServerVariables("HTTP_HOST") = "domain.com" then Response.Redirect("http://www.domain.com") %>