Wednesday, May 13, 2009

Make domain.com point to www.domain.com

 
 

Closed Thread
 
Thread Tools Display Modes
  #1  
Old 01-16-2008, 01:47 PM
areidmtm's Avatar
Moderator
 
Join Date: Feb 2006
Location: Somewhere where I don't know where I am
Posts: 2,161
Default How To make domain.com point to www.domain.com

Open or create a .htaccess file in the /public_html/ directory (if the domain is an add-on domain, then the .htaccess file will be located in add-on domain's directory)

Put this at the top of the .htaccess file (replacing 'domain' with yours)

Code:
 Options +FollowSymlinks RewriteEngine on rewritecond %{HTTP_HOST} ^domain.com [nc] rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]
__________________
Sign Up Now!
Unlimited Storage, Unlimited Transfer, Host Unlimited domain names, 1 Free Domain Name
BlueHost Features | BlueHost Help Desk | Become a BlueHost Affiliate | BlueHost CEO Blog
(888) 401-4678 | Create a support ticket

Last edited by areidmtm; 01-16-2008 at 03:05 PM.
  #2  
Old 01-16-2008, 03:01 PM
Basil's Avatar
Senior Member
 
Join Date: Feb 2006
Location: Florida, USA
Posts: 1,337
Send a message via AIM to Basil
Default

And of course the opposite..
Code:
 RewriteEngine on RewriteCond %{HTTP_HOST} ^www\.domain\.com$ [nc] RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]
  #3  
Old 01-30-2008, 03:07 PM
Junior Member
 
Join Date: Jan 2008
Location: Brazil
Posts: 21
Default

For me it doesnt work. I get a page that says that "This site was moved to this location" and the word "this" is a link to "domain.com" and get an infinite loop.

[EDIT]

Forget. It was a conflict between the wordpress config and .htaccess settings. Changed it in Wordpress Admin Panel and everything is ok.

Last edited by Diogenes; 01-30-2008 at 04:10 PM.
  #4  
Old 02-09-2008, 08:53 AM
Junior Member
 
Join Date: Feb 2008
Posts: 2
Default

Another newbie here.

I've tried to insert your text into a new .htaccess but changing the suffix from ".com" to ".co.uk" however it seems to be redirecting to the ".com".

Options +FollowSymlinks
RewriteEngine on
rewritecond %{HTTP_HOST} ^mydomain.co.uk [nc]
rewriterule ^(.*)$ http://www.mydomain.co.uk/$1 [r=301,nc]


Is there something else I've missed?
  #5  
Old 02-09-2008, 08:59 AM
Basil's Avatar
Senior Member
 
Join Date: Feb 2006
Location: Florida, USA
Posts: 1,337
Send a message via AIM to Basil
Default

Only if something else is redirecting it.
  #6  
Old 02-20-2008, 01:42 AM
Junior Member
 
Join Date: Jan 2008
Location: Sialkot
Posts: 7
Default

Not working for me, site is not opening check www.smsdad.com or check without www site is not opening.("Add-on domain" .htaccess file created in add-on domain directory)
  #7  
Old 02-20-2008, 01:58 AM
Basil's Avatar
Senior Member
 
Join Date: Feb 2006
Location: Florida, USA
Posts: 1,337
Send a message via AIM to Basil
Default

What's in your htaccess file..
  #8  
Old 02-20-2008, 02:36 AM
Member
 
Join Date: Oct 2007
Posts: 56
Default

Quote:
Originally Posted by andyv View Post
Another newbie here.

I've tried to insert your text into a new .htaccess but changing the suffix from ".com" to ".co.uk" however it seems to be redirecting to the ".com".

Options +FollowSymlinks
RewriteEngine on
rewritecond %{HTTP_HOST} ^mydomain.co.uk [nc]
rewriterule ^(.*)$ http://www.mydomain.co.uk/$1 [r=301,nc]


Is there something else I've missed?
You need to place a \ backslash before the periods on the rewritecond. The following is an example of what is working for my site
rewritecond %{HTTP_HOST} ^example\.org [nc]
rewriterule ^(.*)$ http://www.example.org/$1 [r=301,nc]

Try this for your site
rewritecond %{HTTP_HOST} ^mydomain\.co\.uk [nc]

The Apache writeup
http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html
  #9  
Old 02-20-2008, 04:57 AM
Junior Member
 
Join Date: Jan 2008
Location: Sialkot
Posts: 7
Unhappy

Quote:
Originally Posted by Basil View Post
What's in your htaccess file..
this is

Code:
 Options +FollowSymlinks RewriteEngine on rewritecond %{HTTP_HOST} ^smsdad.com [nc] rewriterule ^(.*)$ http://www.smsdad.com/$1 [r=301,nc]
  #10  
Old 02-20-2008, 05:02 AM
Junior Member
 
Join Date: Jan 2008
Location: Sialkot
Posts: 7
Unhappy

Quote:
Originally Posted by arnb View Post
You need to place a \ backslash before the periods on the rewritecond. The following is an example of what is working for my site
rewritecond %{HTTP_HOST} ^example\.org [nc]
rewriterule ^(.*)$ http://www.example.org/$1 [r=301,nc]

Try this for your site
rewritecond %{HTTP_HOST} ^mydomain\.co\.uk [nc]

The Apache writeup
http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html

0 comments: