How to: Several ways in Forcing www or no-www in domain
Posted in: WordPress
This is one of the first thing you need to do after buying a domain. Why do we need to this? If you are thinking about search engine optimization definitely this is important. For instance, donalyza.com redirects to www.donalyza.com. The main purpose of redirecting your domain to your preferred URL is to let Google crawled as one website. The sites that link to donalyza.com will add to the page rank of www.donalyza.com. Basically this only means that it will double your page rank score. Another factor is to avoid duplicate content in search engines.
3 Ways to Force www or no-www (in spirit of no-www.org)
1. Redirects in Cpanel 11
Login to your cPanel account and look for Domains section and click Redirects. Edit the form using your selected URL. Click the image for better viewing.
2. Edit your .htaccess
- to edit your .htaccess, go to your ftp server and download the file. Most of the time it’s in your public_html folder. If you can’t find it create your own .htaccess provided that you enable to view your hidden files. Choose your preferred url and type the code.
-
Force www
-
Force no-www
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(.*)\.donalyza\.com$ [NC]
RewriteRule ^(.*)$ http://www.donalyza.com/$1 [R=301,L]
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.donalyza\.com$ [NC]
RewriteRule ^(.*)$ http://donalyza.com/$1 [R=301,L]
3. Use of WordPress Plugin
- there are times that you don’t use cPanel nor can’t edit your .htaccess. If you are using WordPress platform, make use of this plugins to simply do this stuff for you.
-
Force www
Justin Shattuck’s www-redirect plugin
-
Force no-www
Matt Mullenweg’s a quickie no-www plugin














































if you are using Wordpress 2.3 and above versions, these things are taken care of automatically. no need to install any plugins, or you might end up with infinite redirects. read more about it here.
@marhgil: Thanks for the tip!