Skip to content
Myr

Documented redirect behaviour. Fixes #42

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent cc8332e · Browse files · 1 file+33 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+33 added−0 removed

  • other:+33 added−0 removed

1 file+33 added−0 removed

modified:docs/quickstart.rst+33 added
158 unmodified lines
159`float` like `int` but for floating point values160`path` like the default but also accepts slashes161=========== ===========================================162163.. admonition:: Unique URLs / Redirection Behaviour164165 Flask's URL rules are based on Werkzeug's routing module. The idea166 behind that module is to ensure nice looking and also unique URLs based167 on behaviour Apache and earlier servers coined.168169 Take these two rules::170171 @app.route('/projects/')172 def projects():173 pass174175 @app.route('/about')176 def about():177 pass178179 They look rather similar, the difference is the trailing slash in the180 URL *definition*. In the first case, the canonical URL for the181 `projects` endpoint has a trailing slash. It's similar to a folder in182 that sense. Accessing it without a trailing slash will cause Flask to183 redirect to the canonical URL with the trailing slash.184185 However in the second case the URL is defined without a slash so it186 behaves similar to a file and accessing the URL with a trailing slash187 will be a 404 error.188189 Why is this? This allows relative URLs to continue working if users190 access the page when they forget a trailing slash. This behaviour is191 also consistent with how Apache and other servers work. Also, the URLs192 will stay unique which helps search engines not indexing the same page193 twice.194195196.. _url-building:197198URL Building199````````````
503 unmodified lines