I'm not sure whether this was done intentionally, but the current .htaccess 301 redirect code used to redirect non-www URLs to the www version of the domain actually redirects everything to the home page.
I believe this is incorrect from a SEO standpoint, as well as a end-user usability standpoint.
Example...
Some one has linked to:
http: domain.com/category/specificpage
But when the htaccess 301 redirect kicks in, they're sent to
http: www.domain.com
This is an potential issue for the search engines, and certainly for the user, who isn't shown the content they wanted.
This is the existing code in 5.1 (and I'm pretty sure its in previous versions too)
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule .* http://www.example.com/ [L,R=301]
To (I believe) correctly 301 redirect any given page to its WWW equivalent, I use this code:
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule ^(.*) http://www.example.com/$1 [R=301,L]
Perhaps there is some reason this is not being used? If so, I'd like to hear it - or submit this for consideration into the drupal core?
Comments
Agreed - the second redirect
Agreed - the second redirect looks correct to me. I would submit this as a patch for Drupal 6 (if there is not one already). It might even be viable for backporting.
Cool, I'd say backporting at
Cool, I'd say backporting at least to 5.1 should be considered, as people will be using drupal 5 sites for a long time yet.
I'm not sure how to go about submitting a patch? Never done it before. Could you point me in the right direction?
Thanks for the fix. This has
Thanks for the fix. This has been annoying me, too, but I suck at most things concerning .htaccess. ; )
----------------------
Current Drupal project: http://www.ubercart.org
No problem - thanks for your
No problem - thanks for your custom flatforum theme files which I grabbed from your Ubercart forums... :) I just started using them for a new project. I had a few weird issues with avatars, but in the end I just removed them anyway.
How do I submit this to Drupal Core?
I'm unsure of how to bring this to the attention of those working on Drupal Core?
How can I submit this for review and/or inclusion into Drupal Core?
If you haven't already, you
If you haven't already, you can create an issue for it here:
http://drupal.org/node/add/project-issue/drupal
----------------------
Current Drupal project: http://www.ubercart.org
But this has been already
But this has been already committed to Drupal 5.2
http://cvs.drupal.org/viewvc.py/drupal/drupal/.htaccess?r1=1.81.2.1&r2=1...
.
Ah good
Ah good, glad it finally got fixed!