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 18655 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.

    435 comments

    • Comment Link Stevekerry Wednesday, 02 December 2020 01:34 posted by Stevekerry

      viagra generic how much is viagra when will viagra be generic
      erectile dysfunction treatment https://sildenafilxxl.com/ otc viagra
      generic viagra names how to buy viagra no prescription viagra

    • Comment Link ThomasVob Wednesday, 02 December 2020 00:42 posted by ThomasVob

      cheap erectile dysfunction pill https://sildenafilxxl.com/ viagra online canada

    • Comment Link BruceFut Wednesday, 02 December 2020 00:00 posted by BruceFut

      online viagra prescription generic viagra no prescription viagra
      remedies for ed https://sildenafilxxl.com/ - where can i buy viagra
      best place to buy viagra online viagra online usa cheap generic viagra

    • Comment Link ThomasVob Tuesday, 01 December 2020 23:41 posted by ThomasVob

      levitra without a doctor prescription https://sildenafilxxl.com/ canada viagra

    • Comment Link Stevekerry Tuesday, 01 December 2020 23:15 posted by Stevekerry

      order viagra online buy viagra viagra price comparison
      medication for ed https://sildenafilxxl.com/ where to get viagra
      viagra no prescription generic viagra where can i buy viagra

    • Comment Link BruceFut Tuesday, 01 December 2020 22:00 posted by BruceFut

      viagra generic buy cheap viagra generic viagra online
      pharmacy medications https://sildenafilxxl.com/ - viagra online canadian pharmacy
      cheap viagra viagra viagra from canada

    • Comment Link Stevekerry Tuesday, 01 December 2020 21:34 posted by Stevekerry

      viagra cialis cheap viagra cheap viagra online canadian pharmacy
      mens ed https://sildenafilxxl.com/ mail order viagra
      is there a generic viagra amazon viagra how to buy viagra

    • Comment Link Stevekerry Tuesday, 01 December 2020 19:43 posted by Stevekerry

      viagra otc cheap viagra best over the counter viagra
      erectile dysfunction https://sildenafilxxl.com/ viagra doses 200 mg
      best place to buy viagra online buy viagra over the counter viagra cvs

    • Comment Link ThomasVob Tuesday, 01 December 2020 17:17 posted by ThomasVob

      men with ed https://sildenafilxxl.com/ 100mg viagra

    • Comment Link BruceFut Tuesday, 01 December 2020 14:54 posted by BruceFut

      canadian viagra buy viagra online no prescription viagra
      online ed pills https://sildenafilxxl.com/ - how much will generic viagra cost
      buy viagra online usa buy viagra online how much does viagra cost

    Leave a comment

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