Making sure all your guest are coming in through the same url can be important for SEO. Google may see your domain as two sites depending how you use the WWW and non-WWW url. If Google does pickup both your WWW and non-WWW WordPress site, you may get flagged for duplicate content.
To mitigate these problems, it can be useful to force all users through the same url. For example, on this site, going to http://www.dave.kz/* will be 301 redirected to http://dave.kz/*. To force everyone to use the same URL, open up your .htaccess file. It should look something like this:
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
You’ll need to add these two lines. Make sure you put them in the exact same place.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^dave.kz
RewriteRule (.*) http://dave.kz/$1 [R=301,L]
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Make sure you replace the “!^dave.kz” and “http://dave.kz/” with your domain.
Great, simple guide! Thank you for this.
Thanks, it works. Till now I have used another code for this, and now I see these two lines are working great with WP