Forum Moderators: phranque

Message Too Old, No Replies

Proper use of 302?

         

grandpa

12:36 pm on Jun 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I spotted something in my htaccess that made me think of the documented problems involved with the 302 response code.
This isn't exactly related.. just thinking about the 302 code.

I'm attaching a parameter to my URL for ad campaigns, and strip off the parameter when it arrives.

RewriteCond %{QUERY_STRING} ^ppc=code [NC]
RewriteCond %{HTTP_HOST} ^(.*)$[NC]
RewriteRule ^(.*)$ http://%1/$1? [R=302,L]

The 302 Found says, in part, the client SHOULD continue to use the Request-URI for future requests. But if the Request-URI contains my string I'd rather not have it used again. Something tells me a 301 might be better here... and I might improve my tracking by reducing duplicate URI's with the attached string.

jdMorgan

8:57 pm on Jun 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have used a 301 for removing Adwords tracking query strings, and to good effect. I would not want to use a 302 because, as you noted, it means the client should continue to use the originally-requested URL.

Not sure why you've got that second RewriteCond in there. I'd recommend:


RewriteCond %{QUERY_STRING} ^ppc=code [NC]
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1? [R=301,L]

just to speed up processing a bit.

Jim

grandpa

9:11 pm on Jun 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Not sure why you've got that second RewriteCond in there.
I'm not sure either... that piece of the file hasn't been touched in quite a while. Who knows what I was thinking way back whenever. In all likelyhood I 'borrowed' a code snippet, saw it work ok, and went on to the next item.

Thanks for the confirmation.

larryhatch

10:52 pm on Jun 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm sure there are proper uses for 302 redirects, despite the horrible abuses discussed.

Nevertheless, and being hazy on the concept, I avoid 302 redirects like the black plague.
Same goes for <rel=nofollow>. Both sound like mine-fields to me.
No place for an innocent stroll. -Larry