Hi Frederik,

On Fri, Sep 16, 2016 at 09:01:53AM -0700, Frederik Elwert wrote:
> Hello,
> 
> I am running a site that uses Django 1.8 and Django CMS 3.2. The site is 
> deployed using gunicorn and nginx. Now I noticed a strange, hard to debug 
> issue: When accessing a URL without trailing slash, I expect a redirect to 
> the correct URL with the trailing slash appended, as per the APPEND_SLASH 
> setting. This usually works, but sometimes I get a 404 instead of the 
> correct 301. I can reproduce this using curl:
> 
> $ curl -I http://khk.ceres.rub.de/en/research/focus-groups/notions
> HTTP/1.1 404 NOT FOUND
> Server: nginx/1.6.2
> Date: Fri, 16 Sep 2016 15:54:40 GMT
> Content-Type: text/html
> Connection: keep-alive
> x-xss-protection: 1; mode=block
> Content-Language: en
> x-content-type-options: nosniff
> Vary: Cookie
> X-Frame-Options: SAMEORIGIN
> Set-Cookie: django_language=en; expires=Sat, 16-Sep-2017 15:54:40 GMT; 
> Max-Age=31536000; Path=/
> 
> $ curl -I http://khk.ceres.rub.de/en/research/focus-groups/notions
> HTTP/1.1 301 MOVED PERMANENTLY
> Server: nginx/1.6.2
> Date: Fri, 16 Sep 2016 15:54:42 GMT
> Content-Type: text/html; charset=utf-8
> Connection: keep-alive
> x-xss-protection: 1; mode=block
> Content-Language: en
> x-content-type-options: nosniff
> Vary: Cookie
> Location: http://khk.ceres.rub.de/en/research/focus-groups/notions/
> X-Frame-Options: SAMEORIGIN
> Set-Cookie: django_language=en; expires=Sat, 16-Sep-2017 15:54:42 GMT; 
> Max-Age=31536000; Path=/
> 
> I am a bit clueless why this behaviour is so unpredictable. Any ideas what 
> might be going on here, or how to trace this?

APPEND_SLASH only applies to URLs that do not match any URL pattern.
It is possible that you have a catch-all urlpattern that happens to
match your URL without a trailing slash, and then raise an explicit
404 – this might happen, for instance, if you're using something like
a wiki application, or a custom handler for flatpages, included under
a particular URL prefix.

Good luck,

Michal

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/20160916163757.GY6601%40koniiiik.org.
For more options, visit https://groups.google.com/d/optout.

Attachment: signature.asc
Description: Digital signature

Reply via email to