hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : type domain.com and it loads www.domain.com
Reply

Forum Jump

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

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 09-04-2005, 07:27 PM
jdk jdk is offline
Aspiring Evangelist
 
Join Date: Jul 2004
Posts: 375

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



Sponsored Links
  #2  
Old 09-04-2005, 07:44 PM
jdk jdk is offline
Aspiring Evangelist
 
Join Date: Jul 2004
Posts: 375
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  
Old 09-04-2005, 09:19 PM
Kijit Solutions Kijit Solutions is offline
Disabled
 
Join Date: Jul 2005
Posts: 135
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.

Sponsored Links
  #4  
Old 09-04-2005, 09:34 PM
jdk jdk is offline
Aspiring Evangelist
 
Join Date: Jul 2004
Posts: 375
Thanks I will give it a shot.

  #5  
Old 09-04-2005, 10:03 PM
jdk jdk is offline
Aspiring Evangelist
 
Join Date: Jul 2004
Posts: 375
Nope doesn't work.

  #6  
Old 09-07-2005, 10:37 PM
jdk jdk is offline
Aspiring Evangelist
 
Join Date: Jul 2004
Posts: 375
Anyone else with any suggestions?

Reply

Related posts from TheWhir.com
Title Type Date Posted
UK Police Continue Crackdown on Pirated Content with Torrentz.eu Domain Name Suspension Web Hosting News 2014-05-26 12:30:38
Web Hosting Sales and Promos Roundup - February 7, 2014 Web Hosting News 2014-05-23 15:42:29
Nigeria Internet Registration Association Offers Free ccTLDs to Encourage .ng Domain Adoption Web Hosting News 2014-01-02 14:46:24
Office 365 Integrates GoDaddy Domain Name Registration Web Hosting News 2013-10-09 13:18:05
123-reg Launches Domain Reselling Service on Global Domain Marketplace Web Hosting News 2013-06-19 14:48:10


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?