If you really want Google to use a specific domain style (with or without www) then create a free Google Webmaster Tools account, verify the ownership of your domain (upload a file) and set your preferred domain using the online control panel.
Its that simple, and you don't need to change any server side code, also inbound links with or without www will be treated the same increasing the PageRank of your pages.
Links may point to your site using
both the www and non-www versions of
the URL (for instance,
http://www.example.com and
http://example.com). The preferred
domain is the version that you want
used for your site in the search
results.
Once you tell us your preferred domain
name, we'll take your preference into account when
displaying the URLs. It may take some
time before you see this change fully
reflected in our index.
If you don't specify a preferred domain,
we may treat the www and
non-www versions of the domain as
separate references to separate pages.