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

Apache Server How To Redirect To WWW instaed of getting default http://mysite.com

Discussion in 'Black Hat SEO' started by maxlinks, Feb 15, 2012.

  1. maxlinks

    maxlinks Junior Member

    Joined:
    Jul 4, 2011
    Messages:
    161
    Likes Received:
    5
    Occupation:
    sit at the desk all day
    Location:
    Los Angeles
    I have an appache server with 20 web sites,
    I want them all to be www.mysite.com instead of http://mysite.com

    it seems google picks them up as http://mysite.com and picks up the default web site first, is there a way to tell apache not to go to default website,

    all parameters in sites-enabled are ok (I hope), all pointing to www.

    is there something in the httpd file I should change ?
     
  2. maxlinks

    maxlinks Junior Member

    Joined:
    Jul 4, 2011
    Messages:
    161
    Likes Received:
    5
    Occupation:
    sit at the desk all day
    Location:
    Los Angeles
    Forgot someone once told me to ad

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


    to each web site directory, however , I think my server is bypassing that and going straight to default , only for a few sites, I assume if you dont tell google you want www.mysite.com then they pick out http://mysite.com and then that goes straight to my default site since I indicate www in the sites-enabled configuration.
     
  3. Pekton

    Pekton Regular Member

    Joined:
    Nov 28, 2009
    Messages:
    250
    Likes Received:
    104
    Location:
    upstate ny
    that code is right , did you put it in a .htaccess file in each site directory?
     
  4. maxlinks

    maxlinks Junior Member

    Joined:
    Jul 4, 2011
    Messages:
    161
    Likes Received:
    5
    Occupation:
    sit at the desk all day
    Location:
    Los Angeles
    I will double check, but I suspect that its not even looking in the individual directories and just going to default ?
     
  5. conas

    conas Registered Member

    Joined:
    Dec 24, 2008
    Messages:
    74
    Likes Received:
    37
    use this code:
    PHP:
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteRule http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    Put the code on the .htaccess of the root directory of every site, eg: public_html
     
  6. huzaifaidris

    huzaifaidris Newbie

    Joined:
    Dec 29, 2011
    Messages:
    17
    Likes Received:
    4
    note that using Apache server will make it easy to DDOS your site