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

HTAccess Problem - Some Pro Give me a Hand

Discussion in 'BlackHat Lounge' started by cottonwolf, Apr 12, 2015.

  1. cottonwolf

    cottonwolf Regular Member

    Joined:
    Jan 20, 2015
    Messages:
    469
    Likes Received:
    239
    Hey guys

    I want one domain of mine to run on domain.com, instead of www.domain.com .
    I've got a test site on 000webhost ... yeah, yeah and the following code works there:

    # Do not remove this line, otherwise mod_rewrite rules will stop working
    RewriteEngine on
    RewriteOptions inherit

    RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
    RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]

    Pasting this code above into my bluehost .htaccess file doesn't do anything. I obviously changed the
    domain.com to domain2.com on Bluehost. It actually does exactly the reverse thing, the site goes from
    non-www to www. The non-www is stronger according to MOz, it's an expired domain.
     
  2. snarky

    snarky Junior Member

    Joined:
    Nov 21, 2009
    Messages:
    104
    Likes Received:
    58
    I'm not the pro you're looking for, but try dropping
    RewriteOptions inherit

    The file should be in your root directory, so I'm not sure why you would need the inherit option
     
    • Thanks Thanks x 1
  3. cottonwolf

    cottonwolf Regular Member

    Joined:
    Jan 20, 2015
    Messages:
    469
    Likes Received:
    239
    It didn't work.
    I tried it many ways, and decided to stick www.
    I'm not gonna waste time with this, took too much time already.

     
  4. sysco32

    sysco32 Jr. VIP Jr. VIP

    Joined:
    Feb 5, 2014
    Messages:
    607
    Likes Received:
    226
    Location:
    Skopje/Pecs
    Why don't you redirect the www.domain.com to domain.com at your hosting or where the domain is registered?No need for htaccess.
     
  5. oscilay

    oscilay Regular Member

    Joined:
    Oct 30, 2013
    Messages:
    477
    Likes Received:
    406
    Did you try something like this?


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

    jamie3000 Supreme Member

    Joined:
    Jun 30, 2014
    Messages:
    1,372
    Likes Received:
    625
    Occupation:
    Finance coder looking for semi-retirement
    Location:
    uk
    Sometimes plesk and cpanel can override settings in configuration files you manually set so check that's not happening because those .htaccess rules being suggested look correct and I use them on all my sites
     
  7. l0tterylisa

    l0tterylisa Registered Member

    Joined:
    Dec 10, 2013
    Messages:
    71
    Likes Received:
    3
    Location:
    Internet
    Why not just use a re-direct from within cpanel?
     
  8. cottonwolf

    cottonwolf Regular Member

    Joined:
    Jan 20, 2015
    Messages:
    469
    Likes Received:
    239
    I tried CPanel:
    www to nonwww - result: domain.com redirected to domain.com, instead of www.domain.com redirected to domain.com
    nonwww to www - result: works on other domains properly
    redirect both versions to somedomain - this might not be meant to redirect to the same domain lol, but I tried this too:
    it didn't work XD
    Anyway, it doesn't matter... ratings weren't that too different

    and you do realise that domain.com and somedomain.com get backlinks for these?

    nevermind, close this thread
    thanks for the helpers
     
    Last edited: Apr 13, 2015