Forum Moderators: phranque
I looked in a client's log files to find 301:/ referral errors occuring 100% of the time. It also showed 'no-referal' 99.26%. The site seemingly works fine. I added what I thought to be the proper code to redirect non-www to www a while ago. Although I did find some different code which I believe accomplishes the same thing.
Here is my current .htaccess code...
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mysite.com [NC]
RewriteRule ^(.*)$ [mysite.com...] [L,R=301]
Redirect 301 /directory/page.htm [mysite.com...]
Redirect 301 /directory/page.htm [mysite.com...]
Observations: 1) No where is DirectoryIndex specified - could that be an issue? 2) Should I instead be using this code (in my case i believe I will only need to change www.example.com to www.mysite.com...)
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.html\ HTTP/
RewriteRule ^(([^/]+/)*)index\.html$ http://www.example.com/$1 [R=301,L]
Can anyone tell me...1) If my original non-www to www code is responsible for the 301 referral errors? 2) if my 301 referral errors could be responsible for the site disappearing from the Y! and MSN web results 3) What I should do to my .htaccess to remedy the situation? 4) Is the missing line of code DirectoryIndex index.html an issue?
Thanks in advance. I really appreciate the insight.
Greg
What is a "301 Referral Error"? This is not an Apache term, and in fact, a 301 may of may not be an "error" but if it is, then it is a client error, not a server error. This sound like a pseudo-technical-term from your "Stats" program or something... (?)
2) if my 301 referral errors could be responsible for the site disappearing from the Y! and MSN web results.
Temporarily, yes, if you just recently added the 301 redirect to canonicalize the domain. However, given a month to "figure out" the new preferred domain, most search engines will actually rank your site better, since PageRank and Link-Popularity will no longer be "split" between the two domain variants.
3) What I should do to my .htaccess to remedy the situation?
Probably nothing.
4) Is the missing line of code DirectoryIndex index.html an issue?
No, because the server will have defined it in the VirtualHost container for your domain.
What you *should* do is make sure that all links on your site point to "www.example.com" and not to "example.com" so as not to perpetuate the incorrect/non-preferred domain name. You should also ask your major linking partners to link to you using only the "www" variant, and ask them to change their pre-existing non-www links if possible.
The additional code for "index.html" redirection is only needed if you have linked to "index.html" on your site in the past, and now wish to link only to "/". While this is recommended, it is not required.
Basically, you're dealing with a "neatness counts" issue; Use one domain and only one domain for your site. Always link to any given page in exactly the same way.
In other words, for best results, be utterly consistent. Otherwise, you "confuse" the search engines by forcing them to do back-end analysis of the link-map of your site. They may get it right, or they may get it wrong. Or, they may be overrun with new URLs to process, and never even get to analyzing your site before they have to start the next pass. Either way, if you use inconsistent linking, you put yourself at the mercy of their back-end processing.
Jim