2

I have a page on my website that's targeted at logged-in users only. Logged-out visitors shouldn't see the content.

Imagine the page URL is example.com/upload/.

In cases when users aren't authenticated (logged-out), would a 301, 302 or 404 response be most appropriate? Please explain why in your answer.

3

You could use an error 401 = You are not authorised to view this page

However read this: https://stackoverflow.com/questions/3297048/403-forbidden-vs-401-unauthorized-http-responses

A 301 redirect means that the page has permanently moved to a new location.

A 302 redirect means that the move is only temporary

A 404 redirect means that the page can't be found

| improve this answer | |
  • 1
    401, quote from wiki: HTTP 401 is returned when the client has not authenticated, and implies that a successful response may be returned following valid authentication, – Jasom Dotnet May 27 at 11:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.