开发者

Django ignores APPEND_SLASHES

开发者 https://www.devze.com 2023-03-29 20:35 出处:网络
I\'ve set the APPEND_SLASHES directive to False in my settings.py file and yet Django carries on to redirect some (but not all) requests which is incredibly annoying. What c开发者_运维技巧ould be caus

I've set the APPEND_SLASHES directive to False in my settings.py file and yet Django carries on to redirect some (but not all) requests which is incredibly annoying. What c开发者_运维技巧ould be causing this issue?

Basically, if I make a request without the slash, it will return the correct response body, but with a redirect (301), redirecting it to the same URL but with a slash at the end which will not match because it shouldn't end in a slash.

Is there a fix for that or do I just need to strip the slash redirection code from CommonMiddleware?

Edit: CommonMiddleware is not the culprit. The URL reaches it with a slash at the end.

Edit2: Only happens in Firefox. What the hell? Firebug registers two HTTP requests, one of which is a redirect. Only one request actually hits the server, and it's the one with the slash at the end. The 301 appears out of nowhere and isn't even sent (Wireshark doesn't register it).


301 are permament redirects. So if you have had this option set to true before firefox will still remember this permament redirect and go to page with slash appended. Try to clear firefoxes caches and offline contents.

0

精彩评论

暂无评论...
验证码 换一张
取 消