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 18652 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 Andrewthile Thursday, 03 December 2020 23:57 posted by Andrewthile

      prescription drugs without doctor approval buy Doxycyline canadian pharmacy online
      best male enhancement https://canadianpharmproff.com/ natural ed treatments
      cheap viagra 100mg viagra sale over the counter viagra

    • Comment Link CharlieNaw Thursday, 03 December 2020 22:31 posted by CharlieNaw

      best erectile dysfunction pills cheap generic drugs from india online drug store
      foods for ed https://viagraproff.com/ buy viagra online cheap
      viagra pill generic viagra generic viagra names

    • Comment Link Andrewthile Thursday, 03 December 2020 21:33 posted by Andrewthile

      ed meds online without doctor prescription canada pharmacy online ed meds online
      how much does cialis cost at walmart https://cialisproff.com/ taking l-citrulline and cialis together
      viagra coupons viagra buy real viagra online

    • Comment Link Andrewthile Thursday, 03 December 2020 19:26 posted by Andrewthile

      canada price on cialis cialis for sale average price cialis
      errectile disfunction https://viagraproff.com/ over the counter viagra
      cialis 30 day trial coupon buy cialis is generic cialis safe

    • Comment Link CharlieNaw Thursday, 03 December 2020 17:46 posted by CharlieNaw

      viagra online usa cheap viagra canada viagra
      best ed medicine https://canadianpharmproff.com/ pain meds without written prescription
      where to bay cialis (tadalafil) pills 80mg buy cialis hard erections cialis

    • Comment Link Andrewthile Thursday, 03 December 2020 12:25 posted by Andrewthile

      canadian pharmacy generic viagra cheap viagra viagra coupons
      hims ed pills https://canadianpharmproff.com/ compare ed drugs
      buy real viagra online viagra for sale roman viagra

    • Comment Link CharlieNaw Thursday, 03 December 2020 07:55 posted by CharlieNaw

      ed for men generic Zithromax men ed
      cialis 200mg https://cialisproff.com/ generic cialis at walmart
      viagra discount viagra prices can you buy viagra over the counter

    • Comment Link Stevekerry Thursday, 03 December 2020 03:39 posted by Stevekerry

      generic viagra without a doctor prescription buy cheap viagra mail order viagra
      cheap medications online https://sildenafilxxl.com/ viagra cost
      online doctor prescription for viagra buy viagra generic generic viagra names

    • Comment Link Jesuscap Thursday, 03 December 2020 01:45 posted by Jesuscap

      how to get prescription drugs without doctor https://sildenafilxxl.com/ - viagra cost
      roman viagra generic viagra viagra from canada

    • Comment Link Stevekerry Thursday, 03 December 2020 01:42 posted by Stevekerry

      viagra online viagra price comparison order viagra online
      canadian online drugs https://sildenafilxxl.com/ buy viagra online canada
      cheap generic viagra generic viagra viagra without a doctor prescription

    Leave a comment

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