Forum Moderators: open

Message Too Old, No Replies

Help with redirects

301 or 302?

         

jtoddv

1:13 pm on May 5, 2003 (gmt 0)

10+ Year Member



Is there a difference, as seen by the engines, when one implements a 301 redirect vs. a 302 redirect?

I have a client that has 2 domains, we will call them domainA.com and domainB.com. DomainA.com server redirects to domainB.com with a temporary (302) redirect. This is the way it has been configured since inception.

Now, of the past 3 Google updates, the first 2 were showing domainB.com in the SERPS. This last update, however, domainA.com is now in the SERPS and not domainB.com.

Does a temporary (302) redirect have a different standing with Google than a permenant (301) redirect? Does Google say we will give them 2 months on a temporary and then after that switch back to listing the redirected URL?

If someone else has had any experience with this, I would greatly appreciate it if you would share.

Thanks,
Justin

jdMorgan

3:16 pm on May 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Justin,

A 301-Moved Permanently redirect is different from a 302-Moved Temporarily redirect. A 302 means the move is temporary, and that the resource (e.g. page) will return to the original URL. Therefore, search engines and other "smart" user-agents will not update their database to use the new URL. With a 301, the resource is not expected to return to the original URL, and so smart user-agents will update to use the new URL.

In the situation you describe, a 301 redirect is recommended.

Reference: ftp://ftp.isi.edu/in-notes/rfc2616.txt - RFC2616 Hypertext Transfer Protocol -- HTTP/1.1

HTH,
Jim

DavidT

5:00 pm on May 5, 2003 (gmt 0)

10+ Year Member



Jim,

I recently changed a whole bunch of folder names substituting - for _ . This had the effect of changing the urls for about 500 pages. I did not put in 301 redirects in htaccess except for about 40 of these: the ones that get se referrals.

When robots request the other files the server returns a 302 code. Is that right? Why temporarily moved? I've checked the w3.org page on error codes and that suggests, with a 302 the robot will keep requesting the old url. Then it also sees the same page with a different url and then is there a duplicate content issue?

Thanks,
David

jdMorgan

5:47 pm on May 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



David,

I'd guess that 302 is your server's default redirection mechanism, and no-one has told it otherwise.

Your case is a bit different than Justin's - in that you will have lots of site-internal links "suggesting" to search engines that the URLs have changed. Most search engines will probably take the hint and update the URL.

However, if you want to do this "clean," I'd again recommend a 301 redirect.

If you're on Apache, and you've changed all URLs which had "_" to new URLs with "-", and made no other changes to these URLs, then you could probably accomplish this redirect with a single line of mod_rewrite code in httpd.conf or .htaccess. Assuming that each URL contains only one underscore, then in .htaccess, it would be something like this:


RewriteRule ^([^\_]*)\_([^\_]*)$ http://www.yourdomain.com/$1-$2 [R=301,L]

This translates to "find any number of characters except underscore, followed by an underscore, followed by any number of characters except an underscore." Put the first group of characters into local variable $1, and the second group into local variable $2, and then build the new URL using $1, a hyphen, and $2. Redirect to this new URL using a 301 redirect, and stop rewriting URLs.

Note that the underscores must be "escaped" with a preceding backslash as shown. If a URL contains no underscores, then the RewriteRule will not be invoked. The above code could be expanded to handle multiple underscores in the old URL - I just wanted to illustrate the ease of doing the 301 "globally" for all of your modified URLs.

Reference: Introduction to mod_rewrite [webmasterworld.com]

HTH,
Jim

jtoddv

6:02 pm on May 5, 2003 (gmt 0)

10+ Year Member



Thanks Jim,

I thought the same thing... that they need to change to a 301, but I never realized that a 302 truely meant temporary with the engines and their indexing process. I assumed they would just look at a 302 as a redirect and no further.

Thanks again for your time,
Justin

DavidT

6:40 pm on May 5, 2003 (gmt 0)

10+ Year Member



Thanks also Jim, I have had a look at the intro to mod_rewrite thing a couple of times but it is the sort of thing that will take some time for me to get my head around so to speak.