302 Redirect
The 302 redirection is described in RFC2616: “The requested resource resides temporarily under a different URI. Since the redirection might be altered on occasion, the client SHOULD continue to use the Request-URI for future requests“.
For example, using a 302 redirection from http://www.example.com/ to http://www.example.com/special-action/index.htm, means that, although the page is temporarily redirected to the special action promotional page, the preferred address to be used in the future remains http://www.example.com/. 302 redirects should be used for temporary redirections.
Browsers automatically follow these redirections. They also display the temporary address in the address bar.
The same address pointed to by the redirection will eventually be saved in the browser favorites. Although this is not what should be done according to RFC2616, it does not seem to create many problems in the real world.
302 Redirect and Search Engines
Â
When a URL returns a 302 redirect, it means that the owner of this link asks users to continue to use this address as the redirect could be modified at some later time. The owner of the page pointed to by the redirect is not necessarily the same person and might not wish that its contents is presented as belonging to another web site.
The challenge for search engines is to allocate the content to the appropriate address.
If both addresses belong to the same domain, one can consider that the recommendation of the unique owner has to be followed.
When the addresses belong to different domains, Google and other search engines used to try to follow the rule suggested by RFC2616. This created many technical problems and potential conflicts related to intellectual property rights. After years of confusion, Yahoo and then Google decided to stop attributing a content to a URL of an external site.
The same problem existed with HTML redirects.
302 Redirect Implemented in .htaccess File
Â
Assuming the web server allows it, it is easy to implement a 302 redirect in .htaccess.
Redirecting a page
Redirect /file-name.html http://www.domain.com/temporary-directory/temporary-file-name.htmlRedirecting a directory
Redirect /directory http://www.domain.com/temporary-directoryRedirecting an entire site
Redirect / http://www.temporary-domain.com/
302 Redirect Implemented in a Server Script
Â
The script (typically a PHP, Perl or ASP program) will have to generate a 302 header.
Redirecting a page in PHP
<?php
header(“Location: http://www.domain.com/temporary-address/temporary-file-name.html”);
exit();
?>
Checking if a 302 Redirect Works
InternetOfficer has designed a free on-line tool to check the working of redirects. This new tool to check redirects analyses the HTTP-header and the page contents and identifies in seconds 301 and 302 redirects and HTML redirects (meta refresh).
May 12th, 2007 at 2:45 am
Hi,
Thank you for your service. With regard to use of awstats I might be interested but would need help and your fees are too high.
I’ve read this sentence many times and don’t understand what you are trying to say: “After years of blind obedience to this unpractical rule, Yahoo and then Google decided to stop attributing a content to an external page redirecting to it.” Does it mean that they stopped attributing content to the external page? What does “redirecting to it” add to the sentence? It’s very confusing?
May 12th, 2007 at 8:13 am
Hi Diane,
Thanks for your comments. They help us make the web site better.
I’ve changed the sentence in: “After years of confusion, Yahoo and then Google decided to stop attributing a content to a URL of an external site.”
About the fees, please send an email with your requirements to awstats@internetofficer.com . We will try to find a solution that meet your needs.
July 25th, 2007 at 9:42 pm
To whom it concerns.
Is there a tool out there that can tell me who is redirecting to my website? Which would be the opposite of what this tool does.
Thank you in advance for your time!
Katie
July 27th, 2007 at 5:16 pm
I have been trying to work out about 302redirect but much of the material appears out of date.I have purchased a script similiar to the million dollar home page,The purpose of this to get websites to place an advert with a link to back their website, the script uses a 302 to link to the advertisers website, I have read a lot regarding 302 but cant work out if just by using it can be classed as hijacking. I dont have the knowhow to change this. I certainly dont want to harm either my site or advertisers site. can you tell me if I have a problem.
July 30th, 2007 at 7:35 pm
Katie,
The referring page can be found a number of ways such as this one.
Derek
July 30th, 2007 at 8:17 pm
Derek and Katie,
A “referring page” contains a link that can be a direct link or a redirect. To know the referring page is only a first step when you try to make a list of pages redirecting to your site. You still would need to parse each referring page to check if it contains a direct link or a redirect.
August 29th, 2007 at 1:53 pm
How can you tell if your domain registrar is using a 302 redirect or a 301 redirect?
August 29th, 2007 at 2:03 pm
Our Redirect Checker should help!
December 12th, 2007 at 1:05 am
I am in the process of updating my site http://www.instant-e-store.com/. I have given it a temporary subdomain and put up the new version of the site on that subdomain for testing purposes. Now I am ready to start updating the site by copying everything from the subdomain to the main domain. This process could take a few days depending on how much time I have.
Would it be ok to use a 302 redirect to point my main domain to the subdomain temporarily untill the site is updated?
Thanks for the help 🙂
And thanks for the info about 302 redirects!
December 12th, 2007 at 10:15 am
No redirect is always better than any redirect. But I agree that, in your case if you need several days to copy the files, a 302 temporary redirect is what you should use.
December 17th, 2007 at 12:23 pm
Hi there, I’ve an issue in a website… W3C validator display an 302 redirect when I try to validate my code, I’ve started reading about this mess, 2 days after… i don’t know why it’s redirect…
I don’t have any type of redirection in .htaccess, also my php is clean of redirection… what you think I can check… or what can I read?
Thanks
December 17th, 2007 at 2:18 pm
Hi Gabriel,
I guess that you speak about the site you checked with our redirect checker. 😉
Your web site redirects visitors who disabled cookies. As cookies are disabled in most robots (W3C validator, our redirect checker, Googlebot and other search engine robots), these robots get the “302 redirect” code when they try to view your home page.
December 18th, 2007 at 3:09 pm
tnx a lot :D.. i fix it, it was a cookie redirect on language check, you rocks 😀
December 30th, 2007 at 5:13 pm
Hi,
I would like to create a site with domain name (example) myTest.com. But I would also like to purchase myTests. com (plural – s added) so that those users who accidentally type the url with an ‘s’ would still arrive.
I need a redirect for this, right? I read above that a permanent redirect is better to rank well with Google. What is a a permanent redirection?
Thanks,
Ofer
December 30th, 2007 at 5:22 pm
You are right: you need a permanent redirect from myTests.com to myTest.com. You will find more details in our article about permanent redirects.
February 21st, 2008 at 9:21 pm
Gabriel,
If I have several domains (20) forwarding to one website with content. Is it better to set them as 301 or 302 redirects in regards to being search engine friendly? My main concern is the search engines pick up all domains and relate them to the content of the main website.
Thanks,
Trevor
February 21st, 2008 at 9:41 pm
Hi Trevor,
Use 301 redirects. Google will pass the link juice (pagerank) coming from your 20 domains to the canonical domain (the one with the content).
Jean-Luc
February 21st, 2008 at 11:29 pm
Thanks Jean-Luc. Does this help improve the site rank for the canonical domain too?
February 22nd, 2008 at 9:57 am
It will improve the site rank of the canonical domain, but the 20 other domains will disappear from the SERP’s.
February 27th, 2008 at 11:16 pm
do a 302 redirect pass pagerank to the destination link?
February 27th, 2008 at 11:48 pm
Here is another question… if I use 301 redirects to direct traffic from “Domain1” to “Domain2,” what will the search engines do when a search is made for “Domain1”?
February 28th, 2008 at 8:41 am
Ben,
Yes, a 302 redirect passes some link juice (PageRank) to the destination page. How much ? As much as a 301 redirect ? As much as a regular HTML link ? Only Google knows…
February 28th, 2008 at 8:45 am
Trevor,
What do you call a search for “Domain1” ? There is no content anymore in “Domain1”, if “Domain1” is redirected to “Domain2”.
March 1st, 2008 at 6:59 pm
Thanks for explaining what it is and why it’s important. I think it’s important to know so you know that you are not losing any traffic to your website, or labeled wrong in the search engines.
Terrance Charles
March 6th, 2008 at 2:41 am
this article has been very helpful, thank you
i would appreciate advice on the following scenario:
I have registered a domain called test.com
i also have registered test.com.au (an australian domain)
right now i am concentrating on content for test.com and until i have specific australian content set up, would like test.com.au to redirect to test.com
eventually maybe in a year or so, i will start creating specific content for test.com.au
which redirect should i use so that im not harmed in the search engines?
and secondly, if i use some content/pages from the test.com in my test.com.au will google look negatively upon that as duplicate content? how does one get around that problem?
thanks
March 17th, 2008 at 8:57 pm
Thanks a lot for explaining the 302 redirects. I am running into a huge problem with those as my site appears to be switching from http to https and it causes a redirect error.
April 1st, 2008 at 11:40 pm
I found your information lacking how to show that it’s only temporary. I found this on another website:
Redirect temporary /relative_source_url http://full_destination_url/
The temporary part I think is quite important, especially with 302.
April 2nd, 2008 at 9:02 pm
Hi Zack Katz,
Your Redirect temporary is exactly equivalent to Redirect ! When using Redirect, Apache will assume it is a temporary redirect if not otherwise specified. In other words, all 302’s are temporary redirects.
May 13th, 2008 at 12:16 am
Thanks for the clarification, Jean-Luc.
May 16th, 2008 at 4:13 am
Thanks for your clear advice on this page.
Perhaps you can help me with my problem:
I want to redirect any page in a directory to /new/index.html – specifically to that index page.
When I try:
Redirect 302 /old/ http://www.domain.org/new/index.html
the browser tries to go to:
http://www.domain.org/new/index.htmlWHATEVER.html
(tacking on the filename that was originally called to the redirect)
How can I redirect to a specific file from any page in the original directory?
May 16th, 2008 at 6:22 am
Try this:
RedirectMatch ^\/old\/ http://www.domain.org/new/index.html
May 17th, 2008 at 3:06 am
Fabulous! Just what I needed, thanks so much!
August 14th, 2008 at 7:21 pm
That’s a nice info.
September 25th, 2008 at 6:56 pm
I want to redirect one image to a different URL, but not the whole page. how do I do that? any help please?
September 25th, 2008 at 8:44 pm
In fact, you redirect a URL: the URL can be an image or a page or anything else. In .htaccess, you can have:
Redirect /images/flowers.jpg http://www.site.com/roses.jpg
October 15th, 2008 at 6:32 pm
I’m glad this came up in the top results because you posted exactly what I need. Also, the php script is easier to follow than other methods I saw in the past.
October 24th, 2008 at 11:34 am
Is there a way to assign different “source” information to be passed along with the redirect url?
For example say site example.com links to page flowers.com/flowers.htm which redirects to trees.com
is there a way to have the redirect on flowers.com/flowers.htm change the referral source so trees.com sees the referral as coming from example.com?
October 27th, 2008 at 3:52 pm
Thanks for the post, I was looking for information on how to do a 302 redirect and your site came up #1 on google. And here I am, I have two URLs which I have done a 302 redirect to another. Site A and Site B = 302 redirect to Site C. I have had this for about 7 months now , will this in anyway affect the search performance of my site?Please come back with any negative effect a 302 might cause in the long run. Site C has lost it’s PR 6 , now displays unranked..need help
February 13th, 2009 at 2:17 pm
Thanks for this info.