Redirect example.com to www.example.com for all possible values of example.com

If you wanted to do this generically for all domain names - that is, if you want to redirect example.com to www.example.com for all possible values of example.com, you could use the following recipe:
RewriteCond "%{HTTP_HOST}" "!^www\." [NC]
RewriteCond "%{HTTP_HOST}" "!^$"
RewriteRule "^/?(.*)"      "http://www.%{HTTP_HOST}/$1" [L,R,NE]
These rulesets will work either in your main server configuration file, or in a .htaccess file placed in the DocumentRoot of the server.

This is the best solution when you are looking for redirect non www website to www. 
Dont hesitate about it work or not, but i am sure and well tested. Go for it and add above code on your website.

About Sudhir Kumar

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.

0 σχόλια :

Post a Comment