本文介绍了Django返回HTTP 301?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个django视图,在curl请求上返回HTTP 301:
I have a django view that returns HTTP 301 on a curl request:
grapefruit:~ pete$ curl -I http://someurl
HTTP/1.1 301 MOVED PERMANENTLY
Date: Fri, 16 Oct 2009 19:01:08 GMT
Server: Apache/2.2.9 (Win32) mod_wsgi/2.5 Python/2.6.2 PHP/5.2.6
Location: http://someurl
Content-Type: text/html; charset=utf-8
我无法从curl获取页面内容。
I can't get the page's content from curl. However, if I visit the page with a browser, I see the content as expected.
有没有想法?
感谢,
Pete
Thanks,Pete
推荐答案
您可能请求的网址没有尾部斜杠,并且 APPEND_SLASH
在settings.py中设置为True(默认值),因此Django正在重定向到包含斜线的网址。
You are probably requesting the URL without a trailing slash, and have APPEND_SLASH
set to True (the default) in settings.py, so Django is redirecting to the URL including a slash.
这篇关于Django返回HTTP 301?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!