Handling various types of URL redirects
Generally, when writing HTTP client software, the HTTP protocol provides sufficient information for how to handle redirected URLs. Specifically, if an HT开发者_JAVA百科TP request returns a redirect code of 302 or 307, the redirect should be considered temporary and the client should continue to use the original URL. However, a redirect code of 301 indicates that the client should discard the old URL, and permanently use the redirected URL.
But is there any standard practice for redirects which are NOT issued by the HTTP server itself? In other words, HTML or Javascript redirects? Intuitively, I'd think that an HTML/Javascript-redirect should be handled like a 301, but I'm not sure if this is a good idea.
There are no "redirects" in HTML or JavaScript, all you do is instruct the browser to navigate to another page. Think of it as equivalent to entering a URL in your address bar. There is no question of temporary or permanent here.
精彩评论