XF 1.3 Where to put the code to remove www from your URL?

hi, is this code also automatically redirect indexed link from google ?
example ;
indexed in google with this link : http://www.xenforo.com/community/threads/where-to-put-the-code-to-remove-www-from-your-url.69309/ , when clicked redirected automatically to : http://xenforo.com/community/threads/where-to-put-the-code-to-remove-www-from-your-url.69309/

when I try similar code like this my visitor got 404 error page when accesing from google, but no error when they copy and paste the link manually ...