rewrite quickstart Unique URLs section
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by David Lord · committed by David Lord · parent b16592a · Browse files · 1 file·+13 added−14 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+13 added−14 removed
- other:+13 added−14 removed
Provenance
- Commit
303a3d2- Tree
80d36e5- Author
David Lord <davidism@gmail.com>- Committer
David Lord <davidism@gmail.com>- Parent
b16592a
1 file changed+13 added−14 removed
modified:docs/quickstart.rst+13 added-14 removed
226 unmodified lines227 228 Unique URLs / Redirection Behavior229 ``````````````````````````````````230 231-Take these two rules::231+The following two rules differ in their use of a trailing slash. ::232 233 @app.route('/projects/')234 def projects():235 return 'The project page'1 unmodified line237 @app.route('/about')238 def about():239 return 'The about page'240 241-Though they look similar, they differ in their use of the trailing slash in242-the URL. In the first case, the canonical URL for the ``projects`` endpoint243-uses a trailing slash. It's similar to a folder in a file system; if you244-access the URL without a trailing slash, Flask redirects you to the245-canonical URL with the trailing slash.241+The canonical URL for the ``projects`` endpoint has a trailing slash.242+It's similar to a folder in a file system. If you access the URL without243+a trailing slash, Flask redirects you to the canonical URL with the244+trailing slash.245 247-In the second case, however, the URL definition lacks a trailing slash,248-like the pathname of a file on UNIX-like systems. Accessing the URL with a249-trailing slash produces a 404 “Not Found” error.246+The canonical URL for the ``about`` endpoint does not have a trailing247+slash. It's similar to the pathname of a file. Accessing the URL with a248+trailing slash produces a 404 "Not Found" error. This helps keep URLs249+unique for these resources, which helps search engines avoid indexing250+the same page twice.251 251-This behavior allows relative URLs to continue working even if the trailing252-slash is omitted, consistent with how Apache and other servers work. Also,253-the URLs will stay unique, which helps search engines avoid indexing the254-same page twice.252 253 .. _url-building:254 255 URL Building11 unmodified lines267 2. You can change your URLs in one go instead of needing to remember to268 manually change hard-coded URLs.269 3. URL building handles escaping of special characters and Unicode data270 transparently.271+4. The generated paths are always absolute, avoiding unexpected behavior272+ of relative paths in browsers.274-4. If your application is placed outside the URL root, for example, in273+5. If your application is placed outside the URL root, for example, in274 ``/myapplication`` instead of ``/``, :func:`~flask.url_for` properly275 handles that for you.276 277 For example, here we use the :meth:`~flask.Flask.test_request_context` method572 unmodified lines