Redirect mysite.com to www.mysite.com

For a site in linux hosting, where can I configure that if my website is intended to be accesed without the "www", be redirected immediatly to the one with the "www" ?
 
you can create .htaccess file in root of your domain with following lines :
----------------

Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]

------------------
Just replace domain.com to your actula domain name.
 
Most people I have seen that want to do this implement it in code as the most reliable way.

Or for linux do what Deepak said :) Since replied at the same time, his example is more useful.
 
I did this and seems to work :

Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^mysite\.com [nc]
rewriterule ^(.*)$ http://www.mysite.com/$1 [r=301,nc]
RewriteCond %{REQUEST_URI} !^/foros/
RewriteRule ^(.*)$ /foros/ [r=301,nc]
 
Back
Top