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


    • Comment Link BruceFut Thursday, 03 December 2020 01:20 posted by BruceFut

      viagra prescription buy viagra generic viagra generic
      new ed drugs https://sildenafilxxl.com/ - viagra generic
      canada viagra cheap viagra canadian pharmacy generic viagra

    • Comment Link Stevekerry Wednesday, 02 December 2020 23:29 posted by Stevekerry

      otc viagra buy viagra viagra without prescription
      prescription drugs online without https://sildenafilxxl.com/ viagra for sale
      otc viagra cheap viagra how to get viagra

    • Comment Link Jesuscap Wednesday, 02 December 2020 23:26 posted by Jesuscap

      pills for ed https://sildenafilxxl.com/ - viagra pill
      generic viagra india buy cheap viagra buy viagra online usa

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

      viagra doses 200 mg buy viagra viagra 100mg price
      sexual dysfunction in men https://sildenafilxxl.com/ - buy viagra
      where to get viagra buy viagra online cheap viagra online

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

      where to buy viagra generic viagra canada viagra
      treatments for ed https://sildenafilxxl.com/ - buy viagra online cheap
      buy viagra online cheap viagra 100mg viagra

    • Comment Link Stevekerry Wednesday, 02 December 2020 19:52 posted by Stevekerry

      where can i buy viagra over the counter how to get viagra without a doctor viagra price
      male ed https://sildenafilxxl.com/ online viagra prescription
      viagra online canada generic viagra generic viagra online for sale

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

      viagra canada viagra cheapest viagra online
      cheap medication online https://sildenafilxxl.com/ - where can i buy viagra over the counter
      generic viagra cost generic viagra walmart generic viagra india

    • Comment Link Jesuscap Wednesday, 02 December 2020 15:48 posted by Jesuscap

      online ed medications https://sildenafilxxl.com/ - how much does viagra cost
      generic viagra india generic viagra generic viagra names

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

      viagra pills generic viagra buy viagra online canada
      over the counter ed remedies https://sildenafilxxl.com/ - viagra price comparison
      viagra no prescription viagra viagra prescription

    • Comment Link ThomasVob Wednesday, 02 December 2020 08:04 posted by ThomasVob

      ed treatments https://sildenafilxxl.com/ generic viagra walmart

    Leave a comment

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