"Page not found" when trying to view a URL with a trailing slash

Bug #604569 reported by Andrea Corbellini
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
BeeSeek Website
New
Undecided
Unassigned

Bug Description

Visiting http://www.beeseek.org/about/ (note the slash at the end) leads to a 404 Page not found error. Instead, the site should redirect to the right page (http://www.beeseek.org/about).

Tags: trivial
Revision history for this message
modi.konark (modi-konark) wrote :

The website folder contains a file called url.py which is used to link the pages with URLs.
The pages are matched using regex pattern. Now to solve the problem we need to modify the regex patterns a bit.

They should be of the type:
Syntax:
('^page_name|^page_name/$',Page_Name)

Where:
Page_Name is the page we need to get displayed
page_name is the pattern. I have specified two patterns page_name and page_name

Example:
('^about|^about/$',About)

The first pattern will link to beeseek.org/about and second to beeseek.org/about/.

Hence solving our problem

Revision history for this message
modi.konark (modi-konark) wrote :

Another efficient way to solve the problem is just add '/?' after every pattern something like:

'^about/?$

Revision history for this message
Andrea Corbellini (andrea.corbellini) wrote :

Hi and thanks for looking at this. Your solution will make all 404 errors go away, so this will partially solve the error. However it is not what we want. With your proposal, "bs.org/about" and "bs.org/about/" will return a 200 response and show the same page. But what we want is "bs.org/about/" redirecting (301 response) to "bs.org/about". In this way, we have a unique URL for each page, and not many equivalent URLs that differ just by the number of slashes. So, we need a helper view that catches all URLs ending with one or more "/" and redirects to the right page.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.