www and non-www for WordPress using htaccess (canonicalization)

WordPress uses .htaccess to rewrite the urls for pages, as WordPress calls it, making ‘pretty urls.’ This can however, lead to some confusion when trying to sort out canonicalization issues so that WordPress only uses www or non-www urls. There are a number of plugins that claim to take care of this for you but you can’t beat editing htaccess yourself.

[ad]

Redirect www.domain to non-www.

Replace the existing WordPress htaccess code with the following (obviously changing the domain to yours):