Welcome to WebmasterWorld Guest from 54.167.159.180

Forum Moderators: buckworks & webwork

Message Too Old, No Replies

changing mydomain.com to www.mydomain.com

how does one change from one to the other

     

timciccone

1:47 pm on Jan 3, 2003 (gmt 0)

Inactive Member
Account Expired

 
 


Hi,

Sorry for asking such a simple question, but I am new to this post. Can one use .htaccess to change mydomain.com to www.mydomain.com? I found some examples using RewriteEngine, but I was unable to make it work. Can anyone help? Thank you.

5:33 pm on Jan 3, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
posts:25430
votes: 0


timciccone,

Welcome to WebmasterWorld [webmasterworld.com]!

You might want to check out this Introduction to mod_rewrite [webmasterworld.com] - it will walk you through the process of using mod_rewrite in .htaccess files, including how to test to see if it is available on your server. mod_rewrite is a very powerful tool, and dangerous as a result; I highly recommend you research it before risking a server outage.

Also, you must set up your "Zone file" to indicate that both domain.com and www.domain.com represent the same "account". Contact your host to find out how to do this if it's not already done.

The code to redirect is quite simple, assuming everything else is in order...
in .htaccess:


Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.yourdomain\.com
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [R=permanent,L]

HTH,
Jim

3:51 pm on Jan 8, 2003 (gmt 0)

Junior Member

10+ Year Member

joined:May 16, 2001
posts:48
votes: 0


Hi,

Hopefully you'll be able to clarify.... I was not sure what the difference was between www.domain.com and domain.com. From your post... does that mean a mod_rewrite is needed on my web server to direct people to the same URL? I always thought that both were the same thing...

Thanks for educating me!

6:32 pm on Jan 8, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
posts:25430
votes: 0


wangdy,

www.domain.com is a subdomain of domain.com, just as home.domain.com is.

You do not have to redirect in order to process the user-agent's request - In almost all cases, a request for www.domain.com and for domain.com will return the same content - unless you have set it up otherwise.

The advantage of doing a redirect is to "concentrate" link popularity and "branding" into one domain or the other - you choose.

For example, if you decide to use "domain.com" as your "official" web address, then you would redirect any requests for www.domain.com to domain.com using a 301 redirect. Anyone who typed in "www.domain.com" would see the URL in his address bar "magically" change from [domain.com...] to [domain.com....] This would help prevent other webmasters from linking to your "unofficial" address, and would help to fix "domain.com" in the minds of your visitors for branding purposes.

Advanced robots like Googlebot can figure out when www.domain.com is the same site as domain.com, but there may be others that can't - and so you might end up with two listings on page 3 of the search results instead of one listing on page one.

Hope that clarifies things a little.

Jim
<edit>typos</edit>

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members