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 8374 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 JeffreyMem Tuesday, 26 January 2021 21:02 posted by JeffreyMem

      zithromax over the counter uk: buy zithromax 500mg online - zithromax 500 mg lowest price pharmacy online
      http://kamagrafast100.com kamagra for sale
      buy tadalafil 20mg price tadalafil for sale from india tadalafil generic us

    • Comment Link NmilSmert Monday, 25 January 2021 21:37 posted by NmilSmert

      cipla viagra canada gold viagra x1 discount harmones and viagra [url=http://xz-pharmacyonline.com/en/career-opportunities.html]cheap generic viagra 100mg[/url] ’

    • Comment Link WayneNourl Monday, 25 January 2021 10:37 posted by WayneNourl

      buy prescription viagra online without buy prescription viagra online without
      new erectile dysfunction treatment http://genericvgrshop.com viagra only 0.2$
      prescription viagra online without doctor prescription viagra online without doctor

    • Comment Link FbgSmert Monday, 25 January 2021 06:05 posted by FbgSmert

      viagra interac online natural viagra over the counter viagra and paypal uk no prescription [url=https://canadianpharmacy-usx.com/organic.htm]viagra dubai online[/url] ’

    • Comment Link Gregorytum Sunday, 24 January 2021 00:40 posted by Gregorytum

      prescription viagra online without doctor viagra Without a Doctor Prescription
      mens erection pills http://genericvgrshop.com buying prescription viagra from canada
      meds online without doctor prescription buy generic viagra here

    • Comment Link Jnhjorma Saturday, 23 January 2021 19:18 posted by Jnhjorma

      cialis 36 hour cialis price cialis dapoxetine [url=http://loncialis.com/]original cialis pills[/url] ’

    • Comment Link JosephMat Saturday, 23 January 2021 10:52 posted by JosephMat

      buy generic viagra here generic viagra without a doctor prescription
      best ed medicine http://genericvgrshop.com buy generic viagra
      buy generic viagra here viagra only 0.2$

    • Comment Link KbctSync Saturday, 23 January 2021 01:15 posted by KbctSync

      how can i cialis without custom delayed in canada buy cialis generi cialis [url=http://mycialedst.com/]buy cialis online[/url] ’

    • Comment Link Gregorytum Friday, 22 January 2021 22:17 posted by Gregorytum

      buy medication without an rx prescription viagra online without doctor
      comfortis without vet prescription http://genericvgrshop.com viagra only 0.2$
      medications without a doctor's prescription buy cheap prescription viagra online

    • Comment Link WayneNourl Friday, 22 January 2021 22:07 posted by WayneNourl

      generic viagra without a doctor prescription medications without a doctor's prescription
      over the counter ed http://genericvgrshop.com buy generic viagra here
      medications without a doctor's prescription buy prescription viagra

    Leave a comment

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