If you want to add a script which can redirect user to yoursite with www. in start instead of http://yoursite.com in start you have to create a file .htaccess remember this file do not have any extension cause this file denotes only extension without file name. So go to your Text editor like notepad create a file and save as .htaccess. Include the following code in that file so when user go to your site without www. this script will automatically include http://www. remember redirecting 301 via .htaccess is always search engine friendly and search engine like google will also redirected 301 to http://www. if anyone linked your site or any of your post without http://www. this script will include http://www. in start of each page and post of your website inside that server and directory.
[php]
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
[/php]
Well let’s say you have created a file with .htaccess name and you have inserted above code inside that file now you are ready to upload, you can upload this file into root directory of your domain let’s say where you home page is you can put this there. That will control 301 redirection and visitors to pages or website without http://www. will automatically redirected to http://www. this will also redirect 301 crawlers like google, bing.