Logicationz Tech

More Intelligent Solutionz…!

How to redirect www to non-www and non-www to www URL using .htaccess (mod_rewrite)


Websites can be access with www and without www also. Since Search engines consider http://www.logicationz.com and http://logicationz.com different websites, it might be a case of duplicate content. So you must stick your domain name accessible either with www or without www.

This can be done by writing only two simple lines in your .htaccess file(mod_rewrite in apache). Before writing this rules in .htaccess , make sure that your mod_rewrite is enabled(On). Most probably mod_rewrite is enabled in Linux server but for windows server you need to contact hosting people to make mod_rewrite enabled. You can check this by looking in phpinfo().

Below is the Rules which will redirect all www requests to non-www URL.

RewriteCond %{HTTP_HOST} ^www.logicationz.com$ [NC]
RewriteRule ^(.*)$ http://logicationz.com/$1 [R=301,L]

Redirect 301 means Moved Permanently so most search engines will send visitors directly to the www version of your URL.

Below is the Rules which will redirect all non-www requests to www URL.

RewriteCond %{HTTP_HOST} ^logicationz.com [nc]
RewriteRule (.*) http://www.logicationz.com/$1 [R=301,L]

Redirect 301 means Moved Permanently so most search engines will send visitors directly to the non-www version of your URL.

What you need to do is just replace logicationz with your domain name. Look at below links for more .htaccess rules.

google_protectAndRun(“ads_core.google_render_ad”, google_handleError, google_render_ad);

Advertisements

January 3, 2010 - Posted by | htaccess

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: