1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How Can I 301 My www. To My http://

Discussion in 'Black Hat SEO' started by Poker Rakeback Mafia, Feb 2, 2017.

  1. Poker Rakeback Mafia

    Poker Rakeback Mafia Regular Member

    Joined:
    Sep 22, 2009
    Messages:
    287
    Likes Received:
    58
    Gender:
    Male
    I have links pointing at both, so would like to 301 my www. to my http:// to get the power of both sets of links on my http://
     
  2. Nut-Nights

    Nut-Nights Jr. VIP Jr. VIP

    Joined:
    Jun 20, 2013
    Messages:
    5,058
    Likes Received:
    3,228
    Location:
    Hell
    Home Page:
    I didnt get it, Your website is with www. or without www. http:// remain in both. i am missing something ? you can do that with .htaccess file
     
  3. Poker Rakeback Mafia

    Poker Rakeback Mafia Regular Member

    Joined:
    Sep 22, 2009
    Messages:
    287
    Likes Received:
    58
    Gender:
    Male
  4. RoiBox

    RoiBox Regular Member

    Joined:
    Apr 4, 2009
    Messages:
    237
    Likes Received:
    161
    Occupation:
    Internet Entrepreneur
    Location:
    Gothenburg | Sweden
    Home Page:
    In htaccess:

    Code:
    #Force non-www:
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
    RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
     
    • Thanks Thanks x 1
  5. Poker Rakeback Mafia

    Poker Rakeback Mafia Regular Member

    Joined:
    Sep 22, 2009
    Messages:
    287
    Likes Received:
    58
    Gender:
    Male
    Thank you so much.

    Now a total idiot question. How do I get into htaccess? Can I do it in wordpress backend?
     
  6. topakins

    topakins Junior Member

    Joined:
    Jan 24, 2014
    Messages:
    177
    Likes Received:
    51
    Gender:
    Male
    Location:
    Somewhere in Africa
    Log in to your cpanel, then click on File Manager. From the public_html folder you will see your htaccess. Select it and click on Edit to add the above code
     
    • Thanks Thanks x 2
  7. littlewebdragon

    littlewebdragon Jr. VIP Jr. VIP

    Joined:
    Dec 30, 2007
    Messages:
    1,672
    Likes Received:
    834
    Occupation:
    Occupation
    Location:
    Location
    Do this just as topakins said and just make sure to have show dot files options ticked as if you don't you'll not be able to see .htaccess from file manager in CPanel.
     
    • Thanks Thanks x 1
  8. veldrama

    veldrama Newbie

    Joined:
    Feb 2, 2017
    Messages:
    6
    Likes Received:
    1
    google it, there are many options. The above code is good, insert in your htacces file.
     
  9. mbreezy

    mbreezy Regular Member

    Joined:
    Jun 27, 2012
    Messages:
    469
    Likes Received:
    157
    I would not suggest messing with your .htaccess unless you have the ability or restore it. The rewrite rules can be a bit tricky sometimes.

    All In One SEO, and I think Yoast, has an option to edit your htaccess. For All In One, go the Feature Manager and enable File Editor. Not sure about Yoast.

    Or you can use FTP or cPanel to access your website's root folder.
     
    • Thanks Thanks x 1
  10. RoiBox

    RoiBox Regular Member

    Joined:
    Apr 4, 2009
    Messages:
    237
    Likes Received:
    161
    Occupation:
    Internet Entrepreneur
    Location:
    Gothenburg | Sweden
    Home Page:
    I would suggest messing with it, BUT always take a backup of your .htaccess file, trying is learning, and no one can take knowledge away from you.
     
    • Thanks Thanks x 1
  11. Poker Rakeback Mafia

    Poker Rakeback Mafia Regular Member

    Joined:
    Sep 22, 2009
    Messages:
    287
    Likes Received:
    58
    Gender:
    Male
    Thanks everyone. I'll try the All In One SEO option first. Seems more idiot proof.
     
  12. Poker Rakeback Mafia

    Poker Rakeback Mafia Regular Member

    Joined:
    Sep 22, 2009
    Messages:
    287
    Likes Received:
    58
    Gender:
    Male
    So just to be clear. should I enter the code below into all in one seo?

    #Force non-www:
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
    RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
     
  13. RoiBox

    RoiBox Regular Member

    Joined:
    Apr 4, 2009
    Messages:
    237
    Likes Received:
    161
    Occupation:
    Internet Entrepreneur
    Location:
    Gothenburg | Sweden
    Home Page:
    You need to change the code so that it reflects your domain in it before you do anything more, I have not used "All In One SEO" more then a try a long time ago, so hopefully you can get some help from someone that recommended that plugin for this case.
     
  14. Zwielicht

    Zwielicht Moderator Staff Member Moderator Jr. VIP

    Joined:
    Aug 31, 2013
    Messages:
    6,644
    Likes Received:
    11,790
    Gender:
    Male
    Occupation:
    Private Investigator
    Location:
    Riverside, California
    Home Page:
    What's all of this about plugins and editing your .htaccess file? You can certainly do the latter, but all you really have to do is go to your domain's DNS settings and create a CNAME record for www and set the value to the naked version of your domain.

    If you were using CloudFlare, it would look like this.

    [​IMG]

    Edit: All right, I need to stop posting at 3 in the morning. Somehow, I ended up with 1 broken website, I managed to disconnect my Internet twice, and I think I broke my mouse (good thing I had a spare). I'm tired, I'm going to sleep.
     
    • Thanks Thanks x 1
    Last edited: Feb 3, 2017
  15. RoiBox

    RoiBox Regular Member

    Joined:
    Apr 4, 2009
    Messages:
    237
    Likes Received:
    161
    Occupation:
    Internet Entrepreneur
    Location:
    Gothenburg | Sweden
    Home Page:
    That is also a way to do it, all way┬┤s goes to Rome .. =)
     
  16. agent-x

    agent-x Junior Member

    Joined:
    Apr 4, 2012
    Messages:
    173
    Likes Received:
    34
    Gender:
    Male
    But that won't redirect the browser though will it?
     
  17. redarrow

    redarrow Elite Member

    Joined:
    Apr 1, 2013
    Messages:
    4,372
    Likes Received:
    998
    Why not the cname will point it there...
     
  18. Zwielicht

    Zwielicht Moderator Staff Member Moderator Jr. VIP

    Joined:
    Aug 31, 2013
    Messages:
    6,644
    Likes Received:
    11,790
    Gender:
    Male
    Occupation:
    Private Investigator
    Location:
    Riverside, California
    Home Page:
  19. Zho999

    Zho999 Newbie

    Joined:
    Jul 13, 2016
    Messages:
    20
    Likes Received:
    6
    Gender:
    Male
    If you're using php on your website(something like wordpress) you can throw this into the header instead of messing with the .htaccess file.

    <?php
    $host = $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
    if($host == "http://www.domain.com".$_SERVER['REQUEST_URI']);
    {
    header("HTTP/1.1 301 Moved Permanently");
    header("Location: http://www.New-Website.com".$_SERVER['REQUEST_URI']);
    }
    ?>

    Just make sure it's the first thing on the page. Even before <!DOCTYPE html> portion of the code. The http header should come first.


    Also, mainly for future users who come across this thread, if you do choose to use .htaccess you need to make sure that you can see your "hidden files" in c-panel. I'll add a picture below to show where to find this option in your c-panel file manager.


    First, go to the top right of your c-panel section and click settings.
    file_permissions1.JPG

    Second, find show hidden files (dotfiles), check the box and save.


    permissions_cpanel2.JPG


    Now you should be able a file named ".htaccess".
    .htpic.JPG
     
  20. agent-x

    agent-x Junior Member

    Joined:
    Apr 4, 2012
    Messages:
    173
    Likes Received:
    34
    Gender:
    Male
    Yes but you'll still have two different URLs pointing to the same physical content won't you? I think most websites are setup with a CNAME for www but you still have to take further steps to have www redirect to non-www or vice versa.
     
    • Thanks Thanks x 1