How to force the stite to run from www...?

Discussion in 'Apache' started by pthona, Dec 1, 2006.

Thread Status:
Not open for further replies.
  1. #1
    pthona, Dec 1, 2006 IP
  2. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #2
    
    RewriteEngine On
    Options FollowSymLinks
    RewriteBase /
    
    # Rewrites non-www to www.
    RewriteCond %{HTTP_HOST} !^www\..*
    RewriteCond %{HTTP_HOST}   !^$
    RewriteCond %{HTTP_HOST} ^([^.]*)\.(com|co\.uk)
    RewriteRule ^.*$     http://www.%1.%2%{REQUEST_URI} [R=permanent,L]
    
    Code (markup):
     
    T0PS3O, Dec 1, 2006 IP
  3. YodaCows

    YodaCows Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I would like the same thing, except the other way around.
    I want www to go to http://

    What would my .htaccess look like?

    Thanks.

    ~YC
     
    YodaCows, Dec 1, 2006 IP
  4. stymiee

    stymiee Peon

    Messages:
    427
    Likes Received:
    22
    Best Answers:
    0
    Trophy Points:
    0
    #4
    To the 'www':
    Options +FollowSymlinks 
    RewriteEngine On 
    RewriteCond %{HTTP_HOST} !^(www\.|$) [NC] 
    RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    Code (markup):
    To go from the 'www' to non 'www' use this code:
    Options +FollowSymlinks 
    RewriteEngine On 
    RewriteCond %{HTTP_HOST}//s%{HTTPS} ^www\.(.*)//((s)on|s.*)$ [NC] 
    RewriteRule ^ http%3://%1%{REQUEST_URI} [L,R=301]
    Code (markup):
     
    stymiee, Dec 1, 2006 IP
  5. YodaCows

    YodaCows Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks stymiee!
     
    YodaCows, Dec 1, 2006 IP
Thread Status:
Not open for further replies.