大网数据广告活动
网站运营与故障问答

Which HTTP response status code is most appropriate for a restricted URL?

· 52CE 我爱测

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,…

问题原文

原帖链接 · henrywright · CC BY-SA 3.0

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.

已采纳解答

原帖链接 · Steve · CC BY-SA 3.0

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

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2017-07-03)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。