Tuesday, 10 October 2017 14:36

    How to create Redirect non-www to www using htaccess

    Written by
    Rate this item
    (1 Vote)

    Technically speaking, both www and non-www are 2 different websites and as such may be penalised by search engines for duplicated content. From an SEO perspective it is always best practice to redirect your non-www site URL to www or your wwww. to your non-www version.

    Our site www.accrodigital.com, for example, has a redirection from non-www (http://accrodigital.com) to www (http://www.accrodigital.com). In other, everytime anyone type http://accrodigital.com will be redirected to www.accrodigital.com. Note the "www" in the second URL.

    Technically, the non-www version and the www version are two different domains. So redirecting one to the other improves our SEO. Google and other search engines won't have to worry about two different domains.

    This tutorial will show you how to redirect your whole website to either non-www or www.

    Please note that you will need to find and access your htaccess file. It is located at the root of your website server.

    1. Locate the following line within your htaccess file

    RewriteEngine On

    2. To redirect non-www to www, add this code below it:

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

    3. To redirect www to non-www, add this code after RewriteEngine On:

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

    I hope that this tutorial will help you. Please leave your comment below if any.

    Read 10034 times Last modified on Wednesday, 11 October 2017 07:54
    Fabien Bello

    Fabien Bello has been working in web and app develoment since 1997. He has held numerous positions from game developer to head of creative and product development for major firms such as Xerox, Gala Coral Group. Fabien continues contributing to online community, owns and manages several websites as well as offering consultancy to all size businesses.

    410 comments

    • Comment Link FjjuSmert Tuesday, 02 March 2021 20:45 posted by FjjuSmert

      does viagra work for women http://viagraonlinejc.com/ does viagra make you harder

    • Comment Link LeonardWox Tuesday, 02 March 2021 16:35 posted by LeonardWox

      generic cialis at walmart take cialis with or without food
      does cialis lower your blood pressure https://edplsgeneric.com/ safe alternatives to viagra and cialis
      otc cialis cialis free trial

    • Comment Link NbmoSmert Tuesday, 02 March 2021 14:01 posted by NbmoSmert

      cialis. http://buycialisxz.com/ buy real cialis on line us with american express florida

    • Comment Link RobertPaw Saturday, 27 February 2021 13:38 posted by RobertPaw

      buy viagra cialis liquid cialis source reviews
      cialis dosage 40 mg dangerous https://edplsgeneric.com/ current cost of cialis 5mg cvs
      cialis before and after viagra vs cialis

    • Comment Link LeonardWox Friday, 26 February 2021 22:22 posted by LeonardWox

      cialis online pharmacy how to take cialis
      canadian cialis http://cialisirt.com/ generic for cialis
      coupons for cialis cialis headaches afterwards

    • Comment Link LeonardWox Friday, 26 February 2021 02:16 posted by LeonardWox

      coffee with cialis cheapest cialis web prices
      generic names for cialis and viagra https://edplsgeneric.com/ cheap cialis
      cialis 100 mg lowest price generic cialis tadalafil

    • Comment Link VincentBrubs Thursday, 25 February 2021 01:31 posted by VincentBrubs

      take cialis with or without food herbal replacement for viagra/cialis/levitra...
      cialis generic availability http://cialisirt.com/ otc cialis
      canadian cialis cialis headaches afterwards

    • Comment Link VincentBrubs Tuesday, 23 February 2021 03:43 posted by VincentBrubs

      cialis dosage cialis side effects
      cheapest cialis https://edplsgeneric.com/ cialis 30 day sample
      switching from tamsulosin to cialis real cialis without a doctor's prescription

    • Comment Link RobertPaw Monday, 22 February 2021 05:03 posted by RobertPaw

      cialis headaches afterwards when is the best time to take cialis
      cost of cialis http://cialisirt.com/ free cialis medication for providers
      cialis dosage does viagra or cialis help with pe

    • Comment Link RobertPaw Sunday, 21 February 2021 08:30 posted by RobertPaw

      cialis tolerance daily use of cialis
      fda warning list cialis http://cialisirt.com/ cialis erections
      cialis and interaction with ibutinib real cialis without a doctor's prescription

    Leave a comment

    Make sure you enter all the required information, indicated by an asterisk (*). HTML code is not allowed.