Should I use HTTP 302 instead of HTTP 301 in this case? - http-status-code-301

I have a website example.com
People come to my site to calculate some stuff and get their results like
example.com/result/oiwajefoijh238fjiow
example.com/result/jifomoiemowajefji33
They would spread the links on social networks like Twitter and Facebook.
But I don't want people from those links stay with the suffix. Is it good to do 301 or 302 from example.com/result/oiwajefoijh238fjiow to example.com?
I add those suffix for saving some status and it will be recognized by other servers (rather than browsers)

3×× is mainly used for REDIRECTION.
301 mean MOVED PERMANENTLY
The target resource has been assigned a new permanent URI and any future references to this resource ought to use one of the enclosed URIs.
302 means FOUND
The target resource resides temporarily under a different URI. Since the redirection might be altered on occasion, the client ought to continue to use the effective request URI for future requests.
You can read more here at HTTPSTATUSES

Related

Partial 301 redirects & SEO strategy

This is somewhat of a subjective question. But would like the communities take on this. My client is doing a site split. www.domain1.com will turn in to -- www.domain1.com + www.domain2.com. I know this isn't typically advisable from an SEO perspective, but they are doing it for legal reasons.
Our plan is to only rip out the product pages on www.domain1.com and add those on www.domain2.com everything else on domain1 will stay and everything else on domain2 will be original content. So here's the question, still a good idea to do single page 301 redirects for the pages that are transferred?
www.domain1.com/apples > www.domain2.com/apples
I know that's a bit open-ended, without a ton of detail, but if you have specific examples of where you've done something similar, I'd be curious to know what worked/didn't.
Yes, with a clarification: http 301 is the best for your purpose, because it means permanent redirect (good for SEO, you pass the page and domain authority, link juice...); instead a 302-redirect (http 302) means a temporary redirect, you have no time limits but all the SEO value won't pass! For your purpose, you don't want that.
In general, all pages should be redirected with http 301. Aniyway, with data analysis you can make a decision: if you have a page unuseful, with no traffic, it doesn't need to be redirected, you can use http 404 or http 410 (you can build also a custom 404 page!).
The last thing, must avoid multiple redirects, for example: instead of site1-->site2-->site3 you just need to do: site1-->site3. The reason is each redirect hurts loading speed (also the most common and useful redirect, from http to thhps!!). You just need to avoid multiple ones.

Building new website on old domain name. How should I redirect the old site?

I recently moved a website to another domain, but I am keeping the original domain for a future website. The recently moved website is permanently moved, but I only want traffic to be redirected temporarily to the other domain.
I have read countless 301 vs 302 posts, articles, etc. and have failed to find any that address this particular situation. And no one answered this similar question:
Moving to a new domain and using the old one for a new website - how to handle 301 redirects?
But the difference with my question is: I don't even know that I should be using a 301 redirect for this. What's the best way to handle this situation in general?
301 Moved Permanently doesn't mean that the domain name should never be used again; it means that the content the user requested has moved permanently, which is exactly the situation you describe.
(308 Permanent Redirect is supposed to supplement 301, but it is sometimes treated oddly and doesn't work at all on Windows 7 or 8.1 under IE.)
When you decide to re-use the old domain for a new set of resources, you can simply stop redirecting away from it. By then you hope that people looking for the old resource have updated their bookmarks/links thanks to the 301. It might be polite to allow some duration of time for this transition to occur.
Neither 302 Found nor its replacement 307 Temporary Redirect is appropriate here, as both misrepresent the situation and do not signify that people should permanently look for the old content in the new location: they're going to be mighty confused when the original domain no longer redirects, allegedly the end of a temporary situation, but then also does not serve the expected content.
You can use the .htaccess file to redirect with 307 status code (the successor of 302 in HTTP/1.1)
Redirect 307 / http://other-domain/
Here's a link that you may find helpful. You can also redirect with 308 status code also as #István Rábel suggested

If I set up HSTS on a domain that already implements a 301 redirect, which will take precedence?

Ok, so the scenario is that we have a http domain which currently uses a 301 redirect, we want to change this domain to no longer 301 redirect, and instead to be the main domain for said website.
The problem here is that 301 redirects are cached forever, so this isn't really feasible.
We do however want to change the domain to run on https only, and the https domain doesn't have any redirect set whatsoever.
So I'm wondering if I implement HSTS on a domain that already implements a 301 redirect, will the user be forwarded to the HTTPS version of the page (which currently has no redirect in place). This is presuming that they've already got the 301 redirect cached in their browser.
Unfortunately I can't seem to find any information about whether HSTS or the cached 301 redirect would take precedence.
HSTS should take precedence as that happens in the browser - before any message is sent (or any cached redirect is used in place of a request being sent).
However this is easily enough tested so would suggest you confirm it yourself.
And yes I really wish browsers would honour cache expiry times of 301s and/or expiry them periodically. Pretty annoying.

With redirect code should I use for geoip language redirect?

I have this URL: http://example.com/website/ then I check user country based on geoip and redirect them to: http://example.com/website/en/, http://example.com/website/pt/ etc..
Witch code should I use for this redirect 301, 302 or other?
cheers
You ought to go with 307 Temporary Redirect:
The requested resource resides
temporarily under a different URI.
Since the redirection MAY be altered
on occasion, the client SHOULD
continue to use the Request-URI for
future requests.
That way you won't run into snags with search engines purging the page.
I would go with 303 See Other.

bots and 301 redirect

I have changed the structure of the URLs of my site more than 6 months ago. I detect the use of legacy URLs and redirect to the new URL with a 301 status code. I verified with flidder that the status code is correctly returned upon the request. But bots (yahoo slurps, googlebot, etc.) are still hitting the old URLs. Is there something I am missing?
No, just it takes a very, very long time for crawlers to get the message. I have bots crawling addresses that have not existed since 2005 - when folk harp on with addresses being permanent, they really are.
Additionally, depending on how your URL's are structured, you can disallow the old addresses with robots.txt
Try this and this will only redirect to the bots.
if (preg_match("#(google|slurp#inktomi|yahoo! slurp|msnbot)#si", $_SERVER['HTTP_USER_AGENT'])) {
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.your-main-site.com/");
exit;
}
If external sites have linked to your old pages and those links are still accessible for bots, the bots will keep coming and try to access the content.
mentioned you site address here:
http://www.your-main-site.com/
Thats we use to transfer the domain and sometime for blackhat seo.

Resources