http:// to www

Discussion in 'Site & Server Administration' started by heyman12, May 4, 2008.

  1. #1
    I build and set up websites, and I was asked by my client if I can make "http://domain.com" forward directly to the "http://www.domain.com" How can I do this? I keep thinking its in the DNS control, but I'm not sure. I use GoDaddy btw.
    Because I have absolutly no idea where in the process of publishing to do this, this message may be in the wrong board.
     
    heyman12, May 4, 2008 IP
  2. olddocks

    olddocks Notable Member

    Messages:
    3,275
    Likes Received:
    165
    Best Answers:
    0
    Trophy Points:
    215
    #2
    olddocks, May 4, 2008 IP
  3. wendallb

    wendallb Active Member

    Messages:
    180
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    78
    #3
    Use Mata Refresh:

    <META HTTP-EQUIV="REFRESH" CONTENT="X;URL=yourpage.html">.

    X= seconds delay before refresh, I always use 0

    Your will have refresh to www.domain.com/welcome.html or something
     
    wendallb, May 4, 2008 IP
  4. boltok

    boltok Active Member

    Messages:
    257
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    78
    #4
    The most efficient way is to setup a CNAME record in your DNS. However, with Apache's standard configuration, the user would see the URL in the browser as they entered it. To get Apache to actually change the URL to the new one in the browser, use a Redirect.
     
    boltok, May 5, 2008 IP
  5. alikuru

    alikuru Peon

    Messages:
    44
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    If you are using Apache, try modifying your .htaccess file;
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^example.com
    RewriteRule (.*) http://www.example.com/$1 [R=301,L]
    Code (markup):
    If you are using lighttpd, try this in your lighttpd.conf;
    $HTTP["host"] =~ "^example\.com$" {
            url.redirect = ( "^/(.*)" => "http://www.example.com/$1" )
    }
    Code (markup):
    Or, alternatively, you may use PHP. Edit (or create) your index.php;
    <?php
    if (substr($_SERVER['HTTP_HOST'],0,3) != 'www') {
    	header('HTTP/1.1 301 Moved Permanently'); 
    	header('Location: http://www.'.$_SERVER['HTTP_HOST']
    	.$_SERVER['REQUEST_URI']);
    }
    ?>
    Code (markup):
     
    alikuru, May 11, 2008 IP