homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Visit PubCon.com
Home / Forums Index / WebmasterWorld / Webmaster General
Forum Library, Charter, Moderators: phranque & physics

Webmaster General Forum

but, i want to Forward mydomain.com to www.mydomain.com
Please let me know...

 5:28 am on Dec 25, 2003 (gmt 0)

many of my visitors enters h ttp://mydomain.com
please is there any .httaccess with which the visitors will get to h ttp://www.mydomain.com

thanks.. n advance



 5:38 am on Dec 25, 2003 (gmt 0)

This works for me just fine (changing 'example.com' to the actual domain of course 8^)

RewriteEngine On
RewriteCond %{HTTP_HOST}!^www.example.com [NC]
RewriteRule ^(.*)$ [example.com...] [R,L]

[edited by: heini at 12:03 pm (utc) on Dec. 25, 2003]
[edit reason] examplified, thanks! [/edit]


 5:44 am on Dec 25, 2003 (gmt 0)

Can u please tell me, where to put .htaccess

in the www or in other directory!


 5:49 am on Dec 25, 2003 (gmt 0)


Put your .htaccess file wherever your site's main "index.html" file is. You can put .htaccess files in whatever directory they are needed, but in the case of domain redirection, this needs to be "at the top" of your site's directory structure.

Also, posting code on this board removes a critical space between the "}" and "!" in the 2nd line of code posted above (the work-around is to type two spaces -- one is removed & one remains). In addition, to avoid problems with search engines, I'd strongly suggest using a 301-Moved Permanently redirect, specified by "R=301" in the RewriteRule flags.

The literal "." characters in the RewriteCond pattern should be escaped by preceding them with a "\" character as shown.

You may also need to add Options +FollowSymLinks to the beginning, depending on your server configuration.

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]


[edited by: jdMorgan at 5:52 am (utc) on Dec. 25, 2003]


 5:50 am on Dec 25, 2003 (gmt 0)

i have putted that near to Index.html, but it does not work, i can still see mydomain.com without www


please helpp...

robert adams

 7:23 am on Dec 25, 2003 (gmt 0)

IF you can get to your site with and without the www, then what is the problem? You don't need htaccess, it should work with or without www.


 8:32 am on Dec 25, 2003 (gmt 0)

Robert, please take the time to read through the thread you posted in 3 minutes prior to this [webmasterworld.com]. We explained some of the benefits of this approach.


 7:51 pm on Dec 26, 2003 (gmt 0)

Here's a simple solution that I use... to eliminate the WWW; to INSERT it, keep reading.

Whether someone enters foo.com or www.foo.com, my server searches for index.html in the root directory.

However, the ACTUAL filename of my homepage is home.html

So I created a file named index.html with NOTHING IN THE BODY. Only the following code between the HEAD tags...

<meta http-equiv="REFRESH" content="0; URL=http://foo.com/home.html">

So now, everyone is re-directed to [foo.com...]

No more WWW.


Of course, if you DO want people to get the WWW, then insert that in the URL of the meta tag.


 8:04 pm on Dec 26, 2003 (gmt 0)

The problem with that is that a meta-refresh invokes a 302-Moved Temporarily redirect. Therefore, it will not tell the search engines to 'standardize' on the domain name you are redirecting to, and they will not update their listings of your site or merge your link-popularity or PageRank. As stated above, "...I'd strongly suggest using a 301-Moved Permanently redirect..."


robert adams

 11:59 pm on Dec 29, 2003 (gmt 0)

Robert, please take the time to read through the thread you posted in 3 minutes prior to this. We explained some of the benefits of this approach.

I still don't understand what the problem is. If you type in www.mydomain.com or mydomain.com, it will go to the same place. there is no redirect necessary. If you put a web page (index.html)in your root directory at mydomain.com, then someone types in www.mydomain.com they will see that index.html file, if they type in just the mydomain.com (without the www) they will see the very same index.html file.
There is not one directory for www and one directory for no www. It is all the same server and the same root directory.


 12:09 am on Dec 30, 2003 (gmt 0)

In my case, it has to do with a ton of .cgi scripts I use that work best without the www. (Don't ask me why; that's just what the programmers tell me.) I wanted to eliminate the w's on a site-wide basis for the sake of consistancy. There is also the very important issue of branding, plus SE benefits to using a 301 redirect for www.domain.com to domain.com.

Plus, my domain name is a pretty long one (it's obviously getting much harder to find a short one anymore) and eliminating the w's makes it quicker to tell people where to go to find us online.

robert adams

 4:22 am on Dec 30, 2003 (gmt 0)

I am going to beat this horse once more and if I am dead wrong, somebody hit me upside the head or something.

It doesn't matter because yourdomain.com and www.yourdomain.com are the same thing, there is no difference.
If search engines see them as two different websites, I can see where that might make a difference. But you don't need a redirect or anything. Almost all servers online will let you access the domain with or without the www. The domain name without the www is not a separate domain or even a separate directory,or a separate web page, it is the same exact place.
Therefore, the search engines couldn't possibly see it as "duplicate content" it is the same page.

OK, I'm through now.
Happy New Year everyone,


Global Options:
 top home search open messages active posts  

Home / Forums Index / WebmasterWorld / Webmaster General
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved