Forum Moderators: martinibuster
You can redirect it server side to www.
Marcia's advice is probably going to be the most efficient time wise. All you need to do is set up a 301 permanent redirect for the domain.com to www.domain.com. This will insure that duplication is addressed and transfer the PR to the www. version.
This will prevent future issues that may arise in your link development. You may find yourself spending too much time trying to get everyone to follow a standard.
Jim
See jdMorgans excellent answer:
[webmasterworld.com...]
I used jdMorgans rewrite from the above thread on a test site:
RewriteEngine On
RewriteCond %{HTTP_HOST}!^http://www\.widget\.com [NC]
RewriteRule (.*) [widget.com...] [R=301,L]
It redirected request for mydomain.com to www.mydomain.com *except* requests for a specific page:
mydomain.com/index.html was not redirected to www.mydomain.com/index.html
So I went to Ralf Engelschall's version (which to my very untrained eye looks much the same except for the second RewriteCond statement)
RewriteCond %{HTTP_HOST}!^fully\.qualified\.domain\.name NC]
RewriteCond %{HTTP_HOST}!^$
RewriteRule ^/(.*) [fully.qualified.domain.name...] [L,R]
and I couldn't get that to work at all. Then, when I went back to jdMorgans version and I can't get that to even partially work again.
It might be too much coffee this morning making me overlook something simple stupid (though I am remembering to save the new version before uploading it and am FTPing in ASCII).
Any hints much appreciated.
Jim
I also think should specify R=301 for permanent redirect, because the default (just the R) is a 302, which is temporarily moved.
I know I promised to reply with what worked for me in the thread I referred to, but off-computer life has taken up all my time lately. I'll be back.
The only differences between the two rewrites you tried is that mine is intended for use in per-directory .htaccess, and Engleschall's is intended for use in httpd.conf. Also, a minor difference is that mine forces a 301 redirect, whereas Engleschall's uses the default 302.
The major difference is that in a per-directory environment, the leading slash has already been stripped from the requested URI, and therefore is not present for matching by the RewriteRule. Therefore, it does not appear in my RewriteRule's pattern.
Readers are cautioned that the WebmasterWorld forum software automatically deletes the required space preceding the "!" character in the rewrites above.
If you're still having trouble, post the code you're trying to use now in a new thread in Website Technology or the Scripting forum - Those are the major mod_rewrite hangouts.
Jim
Let's suppose that you have a web site [domain.com...] and you want [domain.com...] to do a client-side 301 error redirect to the [domain.com....] This is useful in several ways:
The client's browser will always show [domain.com,...] not [domain.com....]
Listings in a search engine will always show [domain.com....]
To perform the redirect, suppose that the content for www.domain.com comes from c:\inetpub\www-domain-com:
I would not worry about it. I have been doing this for years. I have several CNAMES aliases. Google just picks the one with the highest PR for display, and ignores the rest.
Now if you are trying to combine all your PR under
one site, yes use the redirects methods mention above.
RedirectPermanent / http://www.domain.com/
there. This is more efficient and MUCH easier to understand. I use this for all sites I set up, and it works perfectly.
I consider the permanent domain.com -> www.domain.com redirect a reasonable default and set this up for all sites I host, solving the problem before my clients even ask. Unfortunately, not all hosting firms take an interest in satisfied customers.