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 18656 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 Tuesday, 01 December 2020 11:09 posted by Stevekerry

      discount viagra viagra buy generic 100mg viagra online
      cheap medications online https://sildenafilxxl.com/ cheapest generic viagra
      where to get viagra buy viagra viagra without a prescription

    • Comment Link Stevekerry Tuesday, 01 December 2020 08:50 posted by Stevekerry

      viagra online usa viagra cost non prescription viagra
      erectional dysfunction https://sildenafilxxl.com/ canadian pharmacy viagra
      where to buy viagra online buy viagra online canada viagra

    • Comment Link Jesuscap Tuesday, 01 December 2020 08:03 posted by Jesuscap

      best drugs for ed https://sildenafilxxl.com/ - best place to buy generic viagra online
      buy viagra online cheap viagra online canadian pharmacy mexican viagra

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

      ed pills that really work https://sildenafilxxl.com/ viagra walgreens

    • Comment Link BruceFut Tuesday, 01 December 2020 03:31 posted by BruceFut

      cheap viagra online buy viagra canadian pharmacy viagra
      drugs online https://sildenafilxxl.com/ - canadian viagra
      buy generic viagra online viagra viagra cost per pill

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

      best ed drugs https://sildenafilxxl.com/ 100mg viagra

    • Comment Link Jesuscap Tuesday, 01 December 2020 02:07 posted by Jesuscap

      canadian drugs https://sildenafilxxl.com/ - walmart viagra
      generic viagra without a doctor prescription buy cheap viagra viagra cost per pill

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

      viagra for sale viagra viagra online usa
      ed pills that work https://sildenafilxxl.com/ - viagra prescription
      viagra 100mg price buy cheap viagra mail order viagra

    • Comment Link Stevekerry Monday, 30 November 2020 22:57 posted by Stevekerry

      over the counter viagra cvs buying viagra online best place to buy viagra online
      online drugs https://sildenafilxxl.com/ viagra online usa
      viagra for sale viagra best place to buy viagra online

    • Comment Link Stevekerry Monday, 30 November 2020 20:59 posted by Stevekerry

      generic viagra online for sale generic viagra viagra cost
      online medication https://sildenafilxxl.com/ how to buy viagra
      viagra pills cheap viagra online doctor prescription for viagra

    Leave a comment

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