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

    394 comments

    • Comment Link JosephMat Friday, 22 January 2021 21:41 posted by JosephMat

      buying prescription viagra from canada generic viagra
      medicine for erectile http://genericvgrshop.com medications without a doctor's prescription
      buy prescription viagra online without buying prescription viagra from canada

    • Comment Link Jbdcfleet Friday, 22 January 2021 18:57 posted by Jbdcfleet

      viagra and cialis rx pharmacy viagra viagra 100mg side effects [url=http://llviabest.com/]cost of viagra 100[/url] ’

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

      buy generic viagra buying prescription viagra from canada
      ed treatment review http://genericvgrshop.com medications without a doctor's prescription
      buy viagra very cheap buy cheap prescription viagra online

    • Comment Link Leroydarly Thursday, 21 January 2021 16:47 posted by Leroydarly

      generic names for cialis and viagra tadalafil yjzjhqdn cialis 20 mg best price
      does viagra or cialis help with pe kpipvfvp http://tadedmedz.online/ buy viagra cialis
      coupon for cialis by manufacturer tadalafil can you have multiple orgasms with cialis

    • Comment Link Richardutera Thursday, 21 January 2021 14:12 posted by Richardutera

      cialis without doctor prescription gxkgjkzb http://tadedmedz.online/ free cialis medication for providers
      online cialis cialis without a doctor's prescription п»їcialis

    • Comment Link Leroydarly Thursday, 21 January 2021 09:39 posted by Leroydarly

      buy viagra cialis cialis canada ioeufttu cialis 20mg
      cialis and interaction with ibutinib sdknleop http://tadedmedz.online/ cialis 100 mg lowest price
      which is better - cialis or viagra cialis canada where to get cialis sample

    • Comment Link NlbxSmert Thursday, 21 January 2021 02:24 posted by NlbxSmert

      5mg of cialis cialis 20mg online cialis cheep [url=http://cialijomen.com/]daily cialis reviews[/url] ’

    • Comment Link Lcxfleet Thursday, 21 January 2021 02:11 posted by Lcxfleet

      generic viagra in canada viagra does viagra work on women [url=http://genqpviag.com/]how can i get viagra in sydney australia[/url] ’

    • Comment Link FbdhSmert Wednesday, 20 January 2021 10:41 posted by FbdhSmert

      cialis 20mg shopping cialis mastercard cheap real cialis [url=http://21cialismen.com/]cialis side effects women[/url] ’

    • Comment Link Fsbxfleet Tuesday, 19 January 2021 21:18 posted by Fsbxfleet

      viagra how much is viagra in the uk problems with kidney with viagra [url=http://genericrxxx.com/]viagra with fast shipping[/url] ’

    Leave a comment

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