Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2004
    Posts
    378

    type domain.com and it loads www.domain.com

    How would I make it so when a user types in my site using domain.com it will automatically open up www.domain.com. An example would be when you type in google.com it goes to www.google.com. I am assuming it is something I can put in an .htaccess file

  2. #2
    Join Date
    Jul 2004
    Posts
    378
    Found the solution for everyone.

    Canonical Hostnames
    Description:
    The goal of this rule is to force the use of a particular hostname, in preference to other hostnames which may be used to reach the same site. For example, if you wish to force the use of www.example.com instead of example.com, you might use a variant of the following recipe.
    Solution:
    # For sites running on a port other than 80
    RewriteCond %{HTTP_HOST} !^fully\.qualified\.domain\.name [NC]
    RewriteCond %{HTTP_HOST} !^$
    RewriteCond %{SERVER_PORT} !^80$
    RewriteRule ^/(.*) http://fully.qualified.domain.name:%{SERVER_PORT}/$1 [L,R]

    # And for a site running on port 80
    RewriteCond %{HTTP_HOST} !^fully\.qualified\.domain\.name [NC]
    RewriteCond %{HTTP_HOST} !^$
    RewriteRule ^/(.*) http://fully.qualified.domain.name/$1 [L,R]

  3. #3
    IMO, this is alot more easier:

    PHP Code:
        $url 'http://www.kijit.com'.$_SERVER['REQUEST_URI'];
        
    $data explode('.'$_SERVER['HTTP_HOST']); 
        
    $first $data[0];
        if (
    $first != 'www')
        { 
    // WWW
            
    header('HTTP/1.0 301 Moved Permanently');
            
    header('Location: '.$url);
            
    header('Connection: close');
            exit;
        } 
    Change "http://www.kijit.com" to whatever you want it directed to.

  4. #4
    Join Date
    Jul 2004
    Posts
    378
    Thanks I will give it a shot.

  5. #5
    Join Date
    Jul 2004
    Posts
    378
    Nope doesn't work.

  6. #6
    Join Date
    Jul 2004
    Posts
    378
    Anyone else with any suggestions?

  7. Newsletters

    Subscribe Now & Get The WHT Quick Start Guide!

Related Posts from theWHIR.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •