double trailing slash in url

85 views
Skip to first unread message

Brian Craft

unread,
Dec 1, 2011, 5:21:21 PM12/1/11
to django...@googlegroups.com
I have a url spec like so:
(r'^foo/$', 'blah')

I just noted from our server logs that if someone mistakenly types two
slashes ('foo//'), the page
gets served, but all of the relative links are broken. It's really
confusing. I believe it should be redirecting or 404ing instead.

I note that foo/bar and foo/bar/ give 404.

I thought that ending in a $ would prevent this from matching.

creecode

unread,
Dec 1, 2011, 5:42:59 PM12/1/11
to django...@googlegroups.com
Hello Brain,

Could it be you are seeing the results of the APPEND_SLASH setting < https://docs.djangoproject.com/en/1.3/ref/settings/#append-slash >.

Toodle-loooooooooo.......
creecode

Brian Craft

unread,
Dec 1, 2011, 6:34:45 PM12/1/11
to django...@googlegroups.com
I don't think so. It's not issuing a redirect. It's just serving the
view, even though the url spec doesn't match.

> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/vjH3Q5JCwXgJ.
> To post to this group, send email to django...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

Karen Tracey

unread,
Dec 2, 2011, 6:11:23 AM12/2/11
to django...@googlegroups.com
On Thu, Dec 1, 2011 at 6:34 PM, Brian Craft <bc...@thecraftstudio.com> wrote:
I don't think so. It's not issuing a redirect. It's just serving the
view, even though the url spec doesn't match.


I suspect your web server is collapsing the multiple slashes into a single one, so that the Django code doesn't even see them.

Try using the dev server to access the url with multiple slashes -- the dev server won't collapse the slashes,  so I suspect you'll see the 404 you are expecting for that case.

Karen
--
http://tracey.org/kmt/

Reply all
Reply to author
Forward
0 new messages