Is a “404 redirect” a legitimate redirect?

2019-06-27 13:21发布

I have a situation where some users may come to mistyped pages, from links, etc. In most situations I can determine the correct page that should be displayed, so I want to redirect to the correct URL.

Is a 301 Redirect appropriate in this case. 301 means "Moved Permanently", but in this case the document wasn't there in the first place. Is it legitimate to set a 404 Not Found header, then redirect to the correct URL?

8条回答
贼婆χ
2楼-- · 2019-06-27 13:35

You can only respond once to an http request - you can't send a 404, and then send a 301. So you are stuck with the 301, I think.

查看更多
霸刀☆藐视天下
3楼-- · 2019-06-27 13:38

I'd use 301. Moved permanently is appropriate in that it tells the accessed page is not there and never will be. If someone has a link to that page, they then know they should update the link.

查看更多
【Aperson】
4楼-- · 2019-06-27 13:42

I think bringing the user to a "did you mean" type of page would be my preference. If you have no suggestions for the "did you mean" content, then give them a real error page and 404 it. Otherwise, leave the pages as status 200 and let the user click through.

I tend to use 301s to redirect previously known and well-established URLs that have changed for some reason. The reason I would worry about the automatic redirect approach is that a flaw in your detection algorithm could possible negatively impact SEO.

查看更多
疯言疯语
5楼-- · 2019-06-27 13:44

you can't redirect with a 404 document. maybe just display a 404 page and suggest some correct URL's. 404 means error. I know google won't be happy seeing those links. :)

查看更多
我只想做你的唯一
6楼-- · 2019-06-27 13:52

I know a 404 can include a redirect header but that sounds really bad to me.

查看更多
乱世女痞
7楼-- · 2019-06-27 13:52

Either use a 301 and do the redirect, or use a 404 and display a message along the lines of "I think you mean 'this URL' instead; update your bookmarks" (and don't redirect).

查看更多
登录 后发表回答