Forum Moderators: phranque
I ran both my fwd'd domains and my main domain through the header checker, both non and www versions, and each time got a http 200 code. I thought that was ok, but I think a 301 redirect is what's needed and recommended.
I then (a couple of days ago) removed all the domains I had under the "Parked domains" area in cPanel. I then went to my registrar and tried the "pointing" there, but that resulted in a 302 redirect which as I understand is NOT wanted. So, I removed it.
Some have sent me these lines below which did not work for the www issue, nor for the domain name redirecting issue:
RewriteEngine on
RewriteRule (.*) [domain.com...] [R=301,L]
and:
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} ^!www\.mysite\.com
RewriteRule (.*) [mysite.com...] [R=301,L]
Details of the software is as follows:
cPanel Build: 10.1.0-RELEASE 30
Linux Kernel version: 2.4.21-4.0.1.ELsmp
Apache version: 1.3.33 (Unix)
I pasted below my htaccess file. I snipped out tons of "IP deny's" where noted (in bold) to make it smaller, but everything else, even the spaces & gaps are exactly as they are in the file. I believe the large area at the bottom where my domains are listed is for the "Hotlink protection". (What I don't understand, is why all of my domains are still there even after I removed them from the "Parked domains" area in cPanel!)
So I'm wondering if someone would be kind enough to simply type some lines that I can paste into my htaccess file to accomplish what I need to do.
----------------
top of page here, no spaces
deny from 201.
deny from 217.
deny from 218.
deny from 219.
deny from 220.
deny from 221.
deny from 38.
snip here
deny from 130.240.
deny from 209.226.
deny from 65.94.
<Files 403.shtml>
order allow,deny
allow from all
</Files>
deny from 209.197.232.
deny from 66.131.
snip here
deny from 67.19.159.148
deny from 69.111.117.130
deny from 209.239.9.181
snip here
deny from 70.85.38.54
RewriteEngine on
RewriteCond %{HTTP_REFERER}!^$
RewriteCond %{HTTP_REFERER}!^http://ForwardedDomain.com/.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://ForwardedDomain.com$ [NC]
RewriteCond %{HTTP_REFERER}!^http://ForwardedDomain2.com/.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://ForwardedDomain2.com$ [NC]
RewriteCond %{HTTP_REFERER}!^http://ForwardedDomain3.com/.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://ForwardedDomain3.com$ [NC]
RewriteCond %{HTTP_REFERER}!^http://ForwardedDomain4.com/.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://ForwardedDomain4.com$ [NC]
RewriteCond %{HTTP_REFERER}!^http://ForwardedDomain5.net/.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://ForwardedDomain5.net$ [NC]
RewriteCond %{HTTP_REFERER}!^http://ForwardedDomain6.com/.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://ForwardedDomain6.com$ [NC]
RewriteCond %{HTTP_REFERER}!^http://ForwardedDomain7.com/.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://ForwardedDomain7.com$ [NC]
RewriteCond %{HTTP_REFERER}!^http://MAINDOMAIN.com/.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://MAINDOMAIN.com$ [NC]
RewriteCond %{HTTP_REFERER}!^http://www.ForwardedDomain.com/.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://www.ForwardedDomain.com$ [NC]
RewriteCond %{HTTP_REFERER}!^http://www.ForwardedDomain2.com/.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://www.ForwardedDomain2.com$ [NC]
RewriteCond %{HTTP_REFERER}!^http://www.ForwardedDomain3.com/.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://www.ForwardedDomain3.com$ [NC]
RewriteCond %{HTTP_REFERER}!^http://www.ForwardedDomain4.com/.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://www.ForwardedDomain4.com$ [NC]
RewriteCond %{HTTP_REFERER}!^http://www.ForwardedDomain5.net/.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://www.ForwardedDomain5.net$ [NC]
RewriteCond %{HTTP_REFERER}!^http://www.ForwardedDomain6.com/.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://www.ForwardedDomain6.com$ [NC]
RewriteCond %{HTTP_REFERER}!^http://www.ForwardedDomain7.com/.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://www.ForwardedDomain7.com$ [NC]
RewriteCond %{HTTP_REFERER}!^http://www.MAINDOMAIN.com/.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://www.MAINDOMAIN.com$ [NC]
RewriteRule .*\.(jpg¦jpeg¦gif¦png¦bmp)$ - [F,NC]
a few empty lines here before the end
-----------------------
Thanks guys.
RewriteCond %{HTTP_HOST} ^domain\.com
RewriteRule (.*) [domain.com...] [R=301,L]
Header check now shows "301 moved permanently".
Someone please tell if that is indeed correct and will work correctly with that htaccess file above. I pasted these lines into my htaccess file immediate after the "RewriteEngine on" line, and then a space below those two lines.
Now this leaves the issue of properly redirecting my other domain names.
Welcome to WebmasterWorld!
A few comments:
This code is correct, with one correction (in bold):
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} [b]!^w[/b]ww\.example\.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
Your referrer-blocking (anti-hotlinking) rules are very redundant. For example, the four lines
RewriteCond %{HTTP_REFERER} !^http://ForwardedDomain.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://ForwardedDomain.com$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.ForwardedDomain.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.ForwardedDomain.com$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?ForwardedDomain\.com [NC]
You will want to leave this code in place for about a year, or until you're sure that all of the 'alternate' domains have completely and finally been removed from the search engine indexes. Remember that occasionally they've been known to revert to olders indices, so don't be in a hurry to remove these lines.
And finally,
>if someone would be kind enough to simply type some lines that I can paste into my htaccess file to accomplish what I need to do.
> Someone please tell if that is indeed correct and will work correctly with that htaccess file above.
It is up to you to understand the code and to test it. If it doesn't work, then report in detail on the symptoms, and we'll try to help. Please see our forum charter for more information and references.
Jim
RewriteEngine on
RewriteCond %{HTTP_HOST}!^www\.domain\.com [NC]
RewriteCond %{HTTP_HOST}!^$
RewriteRule ^(.*) [domain.com...] [L,R=301]
..which seems to be different from you posted. Seems there are many versions of doing this. Can you please explain the difference between what you posted and this one?
Those hotlinking rules were added by cPanel, ;) and thanks on how to consolidate them. So why would they still be there for all of the fwd'd domains when I removed the fwd'd domains from the "Parked domains" area? Since I removed them, I would think the only rules in that area would be for my main domain.
Also, can I, or how do I incorporate my other domain name fwd'ing (301) to my main domain using those lines?
Thanks again for your help.
Almost none; The pattern "." is equivalent to the pattern "!^$", with the former meaning "contains at least one character" and the latter meaning "not empty". The pattern "." is shorter, and therefore faster. Other than that, the first two RewriteConds are in a different order. My code is slightly faster overall.
> Those hotlinking rules were added by cPanel, wink and thanks on how to consolidate them. So why would they still be there for all of the fwd'd domains when I removed the fwd'd domains from the "Parked domains" area? Since I removed them, I would think the only rules in that area would be for my main domain.
Cpanel "knows" that it's likely you'll need to leave those rules in place for awhile, for the reasons noted above. They risk leaving a little clutter versus removing something that will probably be needed for awhile.
> Also, can I, or how do I incorporate my other domain name fwd'ing (301) to my main domain using those lines?
The anti-hotlinking lines? They're not directly-related issues. You still don't want people hotlinking to the old domains, because they would then get redirected to the new domain, and you'd end up with successful hotlinking.
If you mean the new redirection code, that code will redirect any non-www subdomain request to the preferred domain as-is.
In the Google update thread, you expressed the opinion that it is Google's fault that they consider www and non-www domains as separate and that this can result in duplicate content. I'd like to note that www.example.com and example.com can be two completely different and independent web sites. www.example.com is a subdomain of example.com, and the two need have no relationship to each other. The search engines 'merge' them when possible, as a courtesy to webmasters who don't understand domain names, or to those whose hosting services don't understand domain names.
Historically, example.com was often used for an organization's intranet (internal private) site, while www.example.com was used for the public World-Wide-Web site. However, the "www" subdomain has no special relationship to the main domain, any more so than "test" or "production" subdomains might have.
So it's not Google's fault for ascribing two sites to two domains, it's the webmaster's fault for letting it happen. Checking for 'aliased' subdomains and redirecting them to the main domain is one of the first things that should be done when setting up an account on a host default-configured to support alias or wild-card domain names. Otherwise, you forfeit control to the whims of search engines, and to other webmasters who might find it advantageous to link to your site under a variety of subdomain variants, in order to try to cause you trouble.
Jim
Also, can I, or how do I incorporate my other domain name fwd'ing (301) to my main domain using those lines?
I meant how do I use this or can I use this:
RewriteEngine on
RewriteCond %{HTTP_HOST}!^www\.domain\.com [NC]
RewriteCond %{HTTP_HOST}!^$
RewriteRule ^(.*) [domain.com...] [L,R=301]
...to 301 direct my otherdomains.com to maindomain.com? (Please see the first 3 paragraphs in my original post).
Thanks.
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST}!^www\.maindomain\.com
RewriteRule (.*) [maindomain.com...] [R=301,L]