Duplicate content penalty

How do I set a preferred domain url to avoid the search engines
duplicate content penalty.

When I go to http://www.domain.com or http://domain.com they both work
and subsequent urls from there.

In the search engines that could become a duplicate content penalty.

Now I can alter the .htaccess by adding by

RewriteBase /

RewriteCond %{HTTP_HOST} !^www.jasperkooij.com [NC]

RewriteRule ^(.*)$ http://www.jasperkooij.com/$1 [L,R=301]

But can that be made as a default?


That is the easiest way to do it. You could also create a VirtualHost
for that hostname and put this in it:

Redirect Permanent / http://jasperkooij.com/