APPEND_SLASH alters both request urls and target resources #1610

Open
jbazik opened this Issue Jan 23, 2013 · 2 comments

Comments

Projects
None yet
3 participants
Contributor

jbazik commented Jan 23, 2013

APPEND_SLASH does double duty. It generates redirects for requests lacking a trailing slash. It also adds a slash to target urls. That's often what you want, but it makes it impossible to handle those redirects upstream.

So, in my case, I have a site that I want to resolve only slash-appended urls (for seo). But I want to handle redirects upstream (in a reverse proxy), so I set APPEND_SLASH=False. With that setting, non-slash-appended requests to cms pages resolve, instead of generating a 404. (Why do I want to do that? I want to fall back to an alternate site if the page does not exist in the cms).

In urls.py and util/urlutils.py, there are tests for APPEND_SLASH that add the slash.

I'd suggest separating those settings, so that

APPEND_SLASH - only controls redirects from middleware
REQUIRE_SLASH - sets url policy for the cms

To keep things backward-compatible, make the default

REQUIRE_SLASH=APPEND_SLASH

John

Contributor

jbazik commented Jan 23, 2013

I guess that should be CMS_REQUIRE_SLASH.

Member

digi604 commented Jan 23, 2013

Hi John,

The AppendSlash settings is very poorly tested, as it is used by very few users. I would accept a Pull Request for this. If you could find the time to write a test for this as well you would be my hero :)

digi604 added this to the Some Day milestone Feb 10, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment