I want 301 redirect, please tell me which one is right code RewriteEngine on RewriteCond %{HTTP_HOST} ^example\.com [NC] RewriteRule (.*) http://www.example.com/$1 [R=301,L] or RewriteEngine On RewriteCond %{HTTP_HOST} ^domain\.com RewriteRule (.*) http://www.domain.com/$1 [R=301,L] in the first code there is [NC].
You can use both the codes for 301 permanent redirect. The best of the two codes is the first one as it looks more specific. The [NC] makes it look more specific.