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

How to establish your homepage URL with the .htaccess file

Discussion in 'White Hat SEO' started by thedorf, Dec 12, 2013.

  1. thedorf

    thedorf Senior Member

    Joined:
    Oct 1, 2008
    Messages:
    1,193
    Likes Received:
    700
    Occupation:
    what? I gotta have a job?
    Location:
    BHW - Where else?
    The following are different pages in spider's eyes (like Googlebot):

    Code:
    http://YourDomain.com
    http://www.YourDomain.com
    http://www.YourDomain.com/index.html (or index.php)
    although they will all resolve to the same page - this means duplicate content in the search engine's eyes.

    If nothing is done here, the DA/PA/PR/everything else about this website called YourDomain.com will be split amoung these pages, instead of being combined into one which is what most of us want.

    I use the .htaccess method for fixing this as follows:

    Code:
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^YourDomain.com [NC]
    RewriteRule ^(.*) http://www.YourDomain.com/$1 [R=301,L]
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.php\ HTTP/
    RewriteRule ^(([^/]+/)*)index\.php$ /$1 [R=301,L]
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.htm\ HTTP/
    RewriteRule ^(([^/]+/)*)index\.htm$ /$1 [R=301,L]
    
    This will combine all the above access points into one:

    Code:
    www.YourDomain.com
    as long as you are using html or php web pages.
     
  2. Cryptocurrency

    Cryptocurrency Registered Member

    Joined:
    Dec 12, 2013
    Messages:
    62
    Likes Received:
    14
    Thanks for the guide. If you use wordpress, you can select if you want the domain to have www or not.
     
  3. ch8878

    ch8878 Elite Member

    Joined:
    Mar 21, 2009
    Messages:
    2,242
    Likes Received:
    428
    Gender:
    Male
    Occupation:
    Gamer
    Location:
    Youtube
    Home Page:
    Ya what if you want YourDomain.com ?
     
  4. SPQR

    SPQR Elite Member

    Joined:
    May 15, 2013
    Messages:
    1,634
    Likes Received:
    866
    Home Page:
    Then you have to pay a pricy amount. YourDomain.com has 2.5 million backlinks (due to all of these guides). I cannot imagine how much money it generates from that 1&1 affiliate.
     
  5. ch8878

    ch8878 Elite Member

    Joined:
    Mar 21, 2009
    Messages:
    2,242
    Likes Received:
    428
    Gender:
    Male
    Occupation:
    Gamer
    Location:
    Youtube
    Home Page:
    Haha very funny.

    I'm guessing you do this:

    Code:
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^www.YourDomain.com [NC]
    RewriteRule ^(.*) http://YourDomain.com/$1 [R=301,L]
     
  6. sonny3810

    sonny3810 Newbie

    Joined:
    Dec 4, 2013
    Messages:
    17
    Likes Received:
    5
    Nice tutorial. Will try it on my test wordpress blog. Do you also have a tutorial for how to secure your website using .htaccess? Thanks!
     
  7. thedorf

    thedorf Senior Member

    Joined:
    Oct 1, 2008
    Messages:
    1,193
    Likes Received:
    700
    Occupation:
    what? I gotta have a job?
    Location:
    BHW - Where else?
    I *believe*, but I haven't tested this.
     
    • Thanks Thanks x 1
  8. ch8878

    ch8878 Elite Member

    Joined:
    Mar 21, 2009
    Messages:
    2,242
    Likes Received:
    428
    Gender:
    Male
    Occupation:
    Gamer
    Location:
    Youtube
    Home Page:
    You haven't tried then I take it?
     
  9. bartosimpsonio

    bartosimpsonio Jr. VIP Jr. VIP Premium Member

    Joined:
    Mar 21, 2013
    Messages:
    8,903
    Likes Received:
    7,491
    Occupation:
    ZLinky2Buy SEO Services
    Location:
    ⇩⇩⇩⇩⇩⇩⇩⇩⇩⇩⇩⇩
    Home Page:
    Wordpress generates its own .htaccess and you probably shouldn't mess with it directly. Just set the preferred domain via the dashboard configs.