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 10032 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 LeonardWox Saturday, 20 February 2021 21:02 posted by LeonardWox

      cialis pills cheap cialis
      the cost of cialis https://edplsgeneric.com/ generic cialis available
      real cialis without a doctor prescription 5 mg cialis coupon printable

    • Comment Link AbcfSkellalat Thursday, 18 February 2021 22:04 posted by AbcfSkellalat

      viagra online canadian pharmacy http://viagriyvik.com/ viagra copyright

    • Comment Link RobertPaw Thursday, 18 February 2021 19:28 posted by RobertPaw

      cialis dosage low cost cialis
      herbal replacement for viagra/cialis/levitra... http://cialisirt.com/ how much does cialis cost at walmart
      does cialis make you bigger lowest cialis prices

    • Comment Link LeonardWox Thursday, 18 February 2021 14:08 posted by LeonardWox

      cialis going generic in 2019 in us viagra or cialis
      switching from tamsulosin to cialis http://cialisirt.com/ generic cialis black 800mg
      does medicaid cover cialis can you have multiple orgasms with cialis

    • Comment Link LeonardWox Thursday, 18 February 2021 12:11 posted by LeonardWox

      cialis coupon code cialis price
      can you have multiple orgasms with cialis https://edplsgeneric.com/ generic cialis black 800mg
      is cialis generic available expired cialis 3 years

    • Comment Link RobertPaw Thursday, 18 February 2021 09:20 posted by RobertPaw

      current cost of cialis 5mg cvs cialis 20 mg
      cialis generic http://cialisirt.com/ 5mg cialis
      cialis 20 mg best price 5mg cialis

    • Comment Link RobertPaw Thursday, 18 February 2021 05:42 posted by RobertPaw

      viagra or cialis is generic cialis safe
      is cialis generic available https://edplsgeneric.com/ hard erections cialis
      generic cialis black 800mg when is the best time to take cialis

    • Comment Link Charlesneerm Tuesday, 16 February 2021 08:19 posted by Charlesneerm

      ampicillin online cephalexin online
      order doxycycline https://allpillrx.com/ myambutol capsules
      buy minomycin online buy myambutol generic

    • Comment Link Charlesneerm Tuesday, 16 February 2021 06:32 posted by Charlesneerm

      keflex for sale nitrofurantoin tablets
      doxycycline online http://worldrx100.com/ clindamycin capsules
      buy terramycin generic order minomycin

    • Comment Link Fqbbfleet Monday, 15 February 2021 12:28 posted by Fqbbfleet

      payday loan cash in minutes cash advance america bakersfield cash loan shops in doncaster

    Leave a comment

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