Search code examples
usabilityhttp-status-code-401

What staff should be shown for a not logged in user?


I have some private pages on my site. Those pages are accessible only for logged in users. Now, if user is not logged and he tries to visit one of those private pages he gets 301 redirect to an index pages. That's not good for SEO and not user-friendly. What is a good practice to sort it out? Is a good idea to show a sign in form with 401 http status together?


Solution

    • HTTP 301 means that the requested resource was "Moved Permanently"
    • HTTP 401 means that the user is "Unauthorized" to access this resource.

    So yes, presenting a login page with status code 401 is the way to go.

    That's exactly what this status code was thought for.