Mobile app version of vmapp.org
Login or Join
Samaraweera270

: When responding with a HTTP 3xx Redirect status, should there still be a response body? When a service is answering an HTTP request with a "3xx Redirect" status code response (and the accompanying

@Samaraweera270

Posted in: #Http #Redirects

When a service is answering an HTTP request with a "3xx Redirect" status code response (and the accompanying Location header) should it still send a meaningful response body along with the response?

I could imagine that maybe a page providing a link to the redirection target might be helpful if the user agent cannot handle the redirect properly, but is it even realistic to assume that this might happen? And on the other hand, sending only an empty response body might be nice opportunity to save a little bit of traffic ...

Any advise is appreciated.

10.05% popularity Vote Up Vote Down


Login to follow query

More posts by @Samaraweera270

5 Comments

Sorted by latest first Latest Oldest Best

 

@Harper822

Answer is definitely yes to support as many web browsers as possible. There probably is one web browser out there made back in the day that someone uses that doesn't support the location header tag.

On the apache server, the standard 301 redirection message page has the following HTML code:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="http://www.website.com/">here</a>.</p>
</body></html>


and the output is Moved Permanently in large letters with "The document has moved here" underneath with the word "here" as a hyperlink to the new page.

10% popularity Vote Up Vote Down


 

@Eichhorn148

AdBlock or some other plugin was causing some redirects not to happen automatically for me in my browser. This normally wasn't a problem because the redirect usually includes a page with something to click on. There were a few redirect services that didn't include the page and it was annoying.

Most users will never see that content, but there are occasions in which it is useful.

10% popularity Vote Up Vote Down


 

@Kristi941

Actually I just found an answer to my own question addressed in the relevant RFC 7230 (or its predecessor RFC 2616), e.g. in the description of status code "303 See Other":


Except for responses to a HEAD request, the representation of a 303 response ought to contain a short hypertext note with a hyperlink to the same URI reference provided in the Location header field.


Essentially the same advise is given for all status codes of the 3xx family.

10% popularity Vote Up Vote Down


 

@Merenda212

While a response body is not needed (and usually ignored by browsers), it is helpful for people who maintain links to know why a resource URL has been changed. If you put an explanation into the response body, then hopefully the people who linked to the original page will update their links.

10% popularity Vote Up Vote Down


 

@Sherry384

Adding a link to a target page is used traditionally within pages that use a refresh header to redirect users. This is not optimal and not the same as a traditional 301 redirect which is transparent to the user. If you provided HTML as part of the 301 redirect, it will not likely be seen. As well, for may redirects, this opportunity does not exist such as in the case of using an .htaccess RewriteRule.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme