Redirection From Non-Www To Www

Hello.

This is my .htaccess file:




RewriteEngine on


# if a directory or a file exists, use it directly

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d


# otherwise forward it to index.php

RewriteRule . index.php



I just wonder how can I redirect from non-www to www. So if i open

http://mydomain.com/some/thing I just want to redirect it to http://www.mydomain.com/some/thing (301 redirection).

Thanks

Lots of possibilities, including http://stackoverflow.com/questions/12050590/htaccess-redirect-non-www-to-www

But that gives performance issues, as such redirect is costly especially on 3G mobile networks: if you can serve the same content in both cases, just use [font="Courier New"]rel=canonical[/font] declaration in your header, and avoid the redirect.

to redirect from no www to www use htaccess redirect generator to generate the htaccess code