redirect pages to www using javascript

I want to redirect pages e,g ‘’ to '",i.e if anyone access without www then it will be added automatically,how can i do this using javascript?
plz help

it can be done, but i think that wont be the solution you are looking for. because, the javascript based redirect takes place only when the page loads at the client side. Sometimes the difference in http://domain and http://www.domain may not the load the page itself. Besides, you need to add this redirect code to all your pages which is a tedious job.

So, i guess, the permanent and quick solution for your problem is to add a url redirect or rewrite in your htaccess file. In case you are using windows server, you would have to do the same in web.config file.

This is a one place task which applies to all pages in your domain.

Sponsor our Newsletter | Privacy Policy | Terms of Service