Redirection From Non-Www To Www


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 I just want to redirect it to (301 redirection).


Lots of possibilities, including

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