1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to remove www in domain name ?

Discussion in 'Apache' started by lapidus, Mar 8, 2021.

  1. #1
    Hello folks

    I am using Centos,Apache server to hosting my website.

    Can somebody guide me step by step how to remove www in the search field? Please check attachment.
     

    Attached Files:

    lapidus, Mar 8, 2021 IP
  2. RHS-Chris

    RHS-Chris Well-Known Member

    Messages:
    1,007
    Likes Received:
    35
    Best Answers:
    10
    Trophy Points:
    150
    #2
    Hello,

    Try adding the following code to an .htaccess file found in your sites root folder, replacing yourdomain with your own of course:

    
    RewriteEngine On
    RewriteRule ^(.*)$ http://www.yourdomain.com [NC]
    RewriteCond %{HTTP_HOST} ^yourdomain.com/$1 [L,R=301]
    Code (markup):
    Regards,
    Chris
     
    RHS-Chris, Mar 8, 2021 IP
  3. Sumit_Singh

    Sumit_Singh Well-Known Member

    Messages:
    716
    Likes Received:
    64
    Best Answers:
    6
    Trophy Points:
    100
    #3
    It is simple, Login to cpanel and edit .htaccess file (add the following code) to make 301 redirections.
    RewriteEngine On
    RewriteRule ^(.*)$ http://www.yourdomain.com [NC]
    RewriteCond %{HTTP_HOST} ^yourdomain.com/$1 [L,R=301]
    Code (markup):
     
    Sumit_Singh, Mar 8, 2021 IP
  4. lapidus

    lapidus Well-Known Member

    Messages:
    392
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    128
    #4
    Hello Chris

    I got error when i make changes with code you have provide,and i have change to my domain name too. Please check attachment. Regards
     

    Attached Files:

    • hta.jpg
      hta.jpg
      File size:
      29.1 KB
      Views:
      146
    lapidus, Mar 9, 2021 IP
  5. lapidus

    lapidus Well-Known Member

    Messages:
    392
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    128
    #5
    Hello Sumit

    Is not working for me. Can you help me?
     
    lapidus, Mar 12, 2021 IP
  6. liani

    liani Well-Known Member

    Messages:
    69
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    111
    #6
    What’s your web hosting company? Is The website on free hosting or paid one?
     
    liani, Mar 12, 2021 IP
  7. lapidus

    lapidus Well-Known Member

    Messages:
    392
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    128
    #7
    Godaddy VPS
     
    lapidus, Mar 12, 2021 IP
  8. Sumit_Singh

    Sumit_Singh Well-Known Member

    Messages:
    716
    Likes Received:
    64
    Best Answers:
    6
    Trophy Points:
    100
    #8
    Ok if that code not working for you.
    Try this one
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^www\.
    RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
    Code (markup):
    Replace the example(.)com with your domain name. Don't forget to save the .htaccess file in the public.html folder and update it. Once you updated the .htaccess file, open the website in incognito mode or in a different browser (because of caching).
     
    Sumit_Singh, Mar 12, 2021 IP
  9. lapidus

    lapidus Well-Known Member

    Messages:
    392
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    128
    #9
    What can i say man,that i just love you :) Now is working perfectly. Now can you tell me from your view and from view of word of mouth forsearch engines. Did this what we done is better for search engines and why? I was heard that when in domain name is not www then my website will be ranked better example at Google. Is that true and why? Thanks again my friend for helping me
     
    lapidus, Mar 13, 2021 IP
  10. Sumit_Singh

    Sumit_Singh Well-Known Member

    Messages:
    716
    Likes Received:
    64
    Best Answers:
    6
    Trophy Points:
    100
    #10
    My pleasure!

    No, it's a myth. If you have www or not, it has nothing to do with your ranking, even Google itself using a www version. The thing that matters for ranking is to redirect the website only to one domain. For us, both versions of the domain name (www or non-www) are the same because the domain name is what we select to represent our business or brand. If you do not make 301 redirections to redirect your website on a single version (either www or non-www) the search engines consider your domain name as a different version of your website and that affects your rankings.
    Finally, it is up to you what version you like and wants to use but use only one otherwise it will affect your rankings.
     
    Sumit_Singh, Mar 13, 2021 IP
    lapidus likes this.