If you are doing this for canonical purposes, then in your .htaccess In that case RewriteEngine On RewriteCond %{HTTP_HOST} ^example.com RewriteRule (.*) http://www.example.com/$1 [R=301,L] Code (markup): in your htaccess.
Thanks for the reply Lpe04, I use the following RewriteCond %{HTTP_HOST} ^domain.com/administrator RewriteRule (.*) http://www.domain.com/administrator/$1 [R=301,L] but when i go to http://domain.com/administrator it does not redirected to http://www.domain.com/administrator
That is because that is NOT a host. it is a directory. just use what he showed you and you will be fine.
You can also do this by using java script. I don't have it right now but search for "location.replace('url here')". check this and try this may also work.
Doing it with Javascript won't work for all users, and in particular it won't work for search engine crawlers.
Javascript is bad, use rewritemod, or tell your hosting company to do that,or use php. For the php why: 1-read the current url 2-if it starts with : http:// domain . com , replace it with h t t p : / / www . domain . com, save into new string 3-header('location: " . $newurl ); This is the idea, if you don't know how to read ur, replace ... we will help you. BUT ! You need to put that php script in all pages, I hope you use a header in a file if not use htaccess