Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect trailing slashes #100

Closed
trestletech opened this issue May 22, 2017 · 4 comments · Fixed by #746
Closed

Redirect trailing slashes #100

trestletech opened this issue May 22, 2017 · 4 comments · Fixed by #746
Labels
difficulty: advanced Best for maintainers to address effort: medium < 3 days of work priority: medium Could be fixed before next release theme: trailing slash type: enhancement Adds a new, backwards-compatible feature

Comments

@trestletech
Copy link
Contributor

Consider Flask's approach:

@app.route('/projects/')
def projects():
    return 'The project page'

@app.route('/about')
def about():
    return 'The about page'

Though they look rather similar, they differ in their use of the trailing slash in the URL definition. In the first case, the canonical URL for the projects endpoint has a trailing slash. In that sense, it is similar to a folder on a filesystem. Accessing it without a trailing slash will cause Flask to redirect to the canonical URL with the trailing slash.

In the second case, however, the URL is defined without a trailing slash, rather like the pathname of a file on UNIX-like systems. Accessing the URL with a trailing slash will produce a 404 “Not Found” error.

This behavior allows relative URLs to continue working even if the trailing slash is omitted, consistent with how Apache and other servers work. Also, the URLs will stay unique, which helps search engines avoid indexing the same page twice.

@layik
Copy link

layik commented Jun 8, 2018

Hi @trestletech

Is this affecting dynamic routes too? Case is this:
endpoing = /test/<p:double>
IF we then curl /test that is a 404. Whilst curl /test/ would be fine.

Or is this something else?

Thanks

@layik
Copy link

layik commented Jun 8, 2018

or as I update to 0.4.6 things may be slightly different.

@schloerke
Copy link
Collaborator

Perfect Example: #481 (comment)

@schloerke
Copy link
Collaborator

As much as I am against this, there is prior art with apache. Maybe we can make it opt-in...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: advanced Best for maintainers to address effort: medium < 3 days of work priority: medium Could be fixed before next release theme: trailing slash type: enhancement Adds a new, backwards-compatible feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants