Forum Moderators: phranque
thanks.. n advance
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]
in the www or in other directory!
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]
:'(
please helpp...
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.
~Gene
Of course, if you DO want people to get the WWW, then insert that in the URL of the meta tag.
Jim
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.
luck,
robert
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.
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,
robert