Home > OS >  Why do browsers automatically redirect to urls in location?
Why do browsers automatically redirect to urls in location?

Time:01-03

When a response to a certain request is redirection, with status code 3XX and location header, it seems that the browser automatically redirects to the other page (by URLs included in location header).

But when I send the same request via cURL or postman, the response comes with the 3XX but no redirect occurs.

So I concluded that the redirection from the first case is not a basic response but an additional function that browsers.

If so where I can find the settings about this? If not, what is the main cause of this redirection?

CodePudding user response:

The browser is trying to give the user a good experience. If the web site returns a redirect, then the best user experience is for it to go ahead and do the redirect. cURL and wget will also follow the redirects if you enable the option, but since those tools are mostly for diagnostics, the default is to have one request, one response. It's up to the consumer to decide what to do with that response.

I'm not sure what you mean by "basic response". The RFC does not require a redirect. The request receives a response, and it's up to the recipient to decide what to do next.

  • Related