什么是正确的HTTP重定向状态代码

什么是正确的HTTP重定向状态代码

本文介绍了什么是正确的HTTP重定向状态代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的网站上实现了友好的URL,我可以通过URL以两种方式访问​​产品和类别。

I have implemented friendly URL's on my site and I can access products and categories in two ways via the URL.




  1. http://www.example.com/home/electronics/tablets
  2. http://www.example.com/tablets

现在,当URL 导航到,它会执行永久重定向(301)以但这是正确的重定向代码吗?

Now when URL http://www.example.com/tablets is navigated to, it does a permanent redirect (301) to http://www.example.com/home/electronics/tablets but is this the correct redirect code?

我在想也许它应该是303?任何建议都将不胜感激。

I was thinking maybe it should be a 303? Any suggestions would be kindly appreciated.

推荐答案

301是正确的。你总是会在那里重定向。

301 is correct. You are always going to be redirecting there.

302是不合适的,你想要缓存结果。

302 is inappropriate, you want the result to be cached.

303,引用规范,主要是为了允许输出POST激活的脚本将用户代理重定向到选定的资源。新的URI不是最初请求的资源的替代参考。所以这也不合适。

303, to quote the specification, "exists primarily to allow the output of a POST-activated script to redirect the user agent to a selected resource. The new URI is not a substitute reference for the originally requested resource." So that isn't suitable either.

这篇关于什么是正确的HTTP重定向状态代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 05:52