[cc-devel] apache 101 - stripping off the www
Nathan Kinkade
nkinkade at creativecommons.org
Sun Jul 13 15:39:47 EDT 2008
2008/7/13 Mike Linksvayer <ml at creativecommons.org>:
> On Sun, Jul 13, 2008 at 12:23 PM, Nathan Kinkade
> <nkinkade at creativecommons.org> wrote:
>> Here's what we use for creativecommons.org (requires mod_rewrite):
>>
>> RewriteCond %{HTTP_HOST} =www.creativecommons.org
>> RewriteRule ^/(.*)$ http://%{SERVER_NAME}/$1 [L,R=301]
>
> There's a website dedicated to just this, btw -- http://no-www.org :)
>
> Mike
>
Interesting. Their approach was slightly different from the one I
implemented for (cc).org. I guess it just goes to show that there's
more than one way to skin a cat (and also to strip the www from a
domain):
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
I should also note that the approach I listed above is meant to work
from the vhost configuration file, not from an .htaccess file. To
make it work in an .htaccess file change the RewriteRule to:
RewriteRule ^(.*)$ http://%{SERVER_NAME}/$1 [L,R=301]
Nathan
More information about the cc-devel
mailing list