With redirect code should I use for geoip language redirect? - protocols

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.

Related

Should I use HTTP 302 instead of HTTP 301 in this case?

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

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

Force browsers to forget cached redirects?

I inherited a domain that previously had a 301 redirect from the root ("/") to "/index.shtml"
I've removed the redirect and a different site on the domain, but people who visited the site in the past will have the redirect behavior cached in their browsers... for a terribly long time, unless they manually clear their caches.
Anyone trying to go to example.com in these browsers will be sent to example.com/index.shtml before they even make any HTTP requests. Right now this is a huge problem because there is no index.shtml, but is there something I can do with headers to tell browsers to "forget about that redirect you just did!"?
The short answer: There is no way to tell the browsers of the users to "forget" the R 301 redirect. 301 means permanent, it can be only undone on action of the user or when the cache expires.
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.2
Similar Q and A on Stackoverflow:
Apache - how to disable browser caching while debugging htaccess,
Cannot remove 301 redirect
Try to avoid 301 redirects and use 302 (temporarily) instead. Here is an article how to set no cache for 301 redirects (didn't try it):
https://github.com/markkolich/blog/blob/master/content/entries/set-cache-control-and-expires-headers-on-a-redirect-with-mod-rewrite.md
What you could do in your scenario: You could add a header redirect to the file index.shtml, which sends the user to the original file, where he should usually go.
This can be done by a clear data-only cache.
It can remove all,.htaccess redirects changes from the browser.

HTTP Module causing problem with Google Cache

I have a live site ( I can't provide the URL ).
It is on sharepoint 2007. The pages were having a URL, later that was modified.
I wrote a http module and used response.redirect() to navigate user to the correct page.
But since the site was live previously; on searching on google.com, it shows the old URL only. Though the redirection works fine. I need to change the cached URL to new URL.
How can I do that ?
You need to understand the different redirect codes - by itself response.redirect() just redirects a browser (or bot) to another address.
You should have been issuing a 301 redirect then Google and other services (its been roumered that there are a few other games in town) would have eventually removed the old URL and replaced with the new URL and all your 'link juice' would be kept.
If you need to change the URL of a
page as it is shown in search engine
results, we recommended that you use a
server-side 301 redirect. This is the
best way to ensure that users and
search engines are directed to the
correct page. The 301 status code
means that a page has permanently
moved to a new location.
ASP.NET code for this
Response.Status = "301 Moved Permanently"
Response.addheader "Location", "http://www.newdomain.com/newurl/"
Response.end
Try to look here. Not sure, but it can help you.

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