Forum Moderators: phranque

Message Too Old, No Replies

301 vs. 302 when using mod_rewrite to force "www."

         

moheybee

12:17 am on Mar 14, 2005 (gmt 0)

10+ Year Member



My website has been around for almost 5 years. I've recently started using mod_rewrite to force "www." at the beginning of the domain:
RewriteCond %{HTTP_HOST} ^domain\.com
RewriteRule ^/(.*) [domain.com...] [R=301,L]

I just assumed to use the 301 "Moved Permanently" redirect, but the other day I noticed that Google uses 302 "Moved":

$ curl google.com
<HTML><HEAD><TITLE>302 Moved</TITLE></HEAD><BODY>
<H1>302 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>

301 makes more sense and I'm thinking it might be one of those situations where Google pulls the "do as I say, not as I do".

Thoughts?

moheybee

12:20 am on Mar 14, 2005 (gmt 0)

10+ Year Member



Also, if I have a bunch of domain names that are misspellings of the actual one, should I use a 301 or 302 or does it even matter?

eurotrash

12:22 am on Mar 14, 2005 (gmt 0)

10+ Year Member



My advice from a Google sales engineer was 301.

moheybee

12:31 am on Mar 14, 2005 (gmt 0)

10+ Year Member



For both the www forcing and the misspelling domains?

sitz

2:14 am on Mar 14, 2005 (gmt 0)

10+ Year Member



Depends on how confident you are in 'permanent', really. I tend not to use 301's because I rarely (if ever) know what I may have to do the next day. Also note that 301 responses are cacheable (subject to any Cache-Control headers you send with the response); 302 responses are /not/ cacheable. Something to keep in mind.

moheybee

2:42 am on Mar 14, 2005 (gmt 0)

10+ Year Member



Thanks for the info sitz.

I never knew that about 301's being cached.