Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
See http://drupal.org/node/107659.
.htaccess file should be:
...
# If you want the site to be accessed only WITHOUT the www. prefix, adapt
# and uncomment the following:
# RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
# RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
...
Comment | File | Size | Author |
---|---|---|---|
#15 | patch_125.txt | 1.78 KB | webernet |
#14 | patch6x.txt | 725 bytes | webernet |
#12 | patch_124.txt | 1.76 KB | webernet |
#6 | patch_122.txt | 1.57 KB | webernet |
#2 | htaccess_11.patch | 1.81 KB | ff1 |
Comments
Comment #1
cog.rusty CreditAttribution: cog.rusty commentedI agree and I also suggest a change in the comment.
With the current comment, people (myself included) at first tend to think that if you type www then you won't be able to access the site. This looks better:
The same for the other case.
Comment #2
ff1 CreditAttribution: ff1 commentedPatch created.
Comment #3
abhigupta CreditAttribution: abhigupta commentedI tested the patch. It works.
Please commit it to Drupal.
Comment #4
ff1 CreditAttribution: ff1 commentedChanged version to 6.x-dev as this issue is certainly still valid in the current HEAD .htaccess file.
I'm not sure if the patch needs to be rerolled for 6.x-dev, so I've also changed the status back to code needs review.
Is this the right way to do this? Or should I have raised a new issue for 6.x-dev? If anyone knows, please let me know.
Comment #5
BioALIEN CreditAttribution: BioALIEN commentedI made this change to all our Drupal sites last month. I was just about to open an issue for this till I came across this one.
+1, this is a must have for D6 and should be back ported to D5.
Setting priority to critical as this actually affects a site's SEO since all 301 links are pointed to the homepage rather than to the correct relative URLs.
Comment #6
webernet CreditAttribution: webernet commentedRerolled, and cleaned up the comments.
Comment #7
BioALIEN CreditAttribution: BioALIEN commentedAnd here comes the RTBC :)
Comment #8
ff1 CreditAttribution: ff1 commentedI'm not sure that the cleaned up comments have helped with the understanding of the no-www issue. We are not forcing users to use www. or not use www., we are just redirecting users if they visit our non-preferred address.
The current patch looks like this:
I think it should be changed to this:
I think this clarifies the no-www problem for both advanced and novice users.
Comment #9
ff1 CreditAttribution: ff1 commentedChanged status back to 'code needs review'.
Comment #10
Senpai CreditAttribution: Senpai commentedI agree with the language of the revision. It brings clarity to novices and yet allows more advanced users to easily grasp the either/or scenario without having to think about it. And nobody should make us think. ;)
++ from me, and yeah, this does need to be back-ported to version 5.2. I've been running my personal sites with this same modified rewrite rule for months now, and they seem to work fine. Who's the maintainer for 5.x? Someone should make sure they see this.
Comment #11
Dries CreditAttribution: Dries commentedLooks OK. In the code comments, url should probably be URL. Feel free to roll a patch and to mark this RTBC.
Comment #12
webernet CreditAttribution: webernet commentedRerolled.
- Expanded comments (not identical to those suggested).
Comment #13
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD. Thanks all!
Comment #14
webernet CreditAttribution: webernet commentedJust noticed a typo.
Attached is the fix for 6.x
Comment #15
webernet CreditAttribution: webernet commentedHere is the corrected patch against 5.x so it can be back ported.
Comment #16
Dries CreditAttribution: Dries commentedCommitted the typo-fix to CVS HEAD. Thanks.
Comment #17
drummCommitted to 5.
Comment #18
(not verified) CreditAttribution: commented