Steve Piercy - Web Site Builder Trailing slashes in Knop
Sep 19, 2010; 04:59
Steve Piercy - Web Site Builder
Trailing slashes in Knop
While comparing stuff between Flask (a python framework) and Knop, I read the following in the Flask docs (scroll down to "Unique URLs / Redirection Behavior"):
FlaskÄôs URL rules are based on WerkzeugÄôs routing module. The idea behind that module is to ensure nice looking and also unique URLs based on behaviour Apache and earlier servers coined.
Take these two rules:
@app.route('/projects/') def projects(): pass
@app.route('/about') def about(): pass
They look rather similar, the difference is the trailing slash in the URL definition. In the first case, the canonical URL for the projects endpoint has a trailing slash. ItÄôs similar to a folder in that sense. Accessing it without a trailing slash will cause Flask to redirect to the canonical URL with the trailing slash.
However in the second case the URL is defined without a slash so it behaves similar to a file and accessing the URL with a trailing slash will be a 404 error.
Why is this? This allows relative URLs to continue working if users access the page when they forget a trailing slash. This behaviour is also consistent with how Apache and other servers work. Also, the URLs will stay unique which helps search engines not indexing the same page twice.
So I tested this in the Knop demo and my recent referee send off app using the grid object. In the Knop demo, login and visit:
http://myknopinstall.com/advanced/
Enter a search term. It works as expected. Now try this:
http://myknopinstall.com/advanced
Uh-oh. We get the -default item (Customers Simple) for the Knop nav object.
I wondered whether that is deliberate or an effect of clean URLs and Apache?
Is there some reasoning behind requiring a trailing slash?
--steve
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- Steve Piercy Web Site Builder Soquel, CA <web@StevePiercy.com> <http://www.StevePiercy.com/>
-- ############################################################# This message is sent to you because you are subscribed to the mailing list <knop@lists.montania.se>. To unsubscribe, E-mail to: <knop-off@lists.montania.se> Send administrative queries to <knop-request@lists.montania.se> List archive http://www.nabble.com/Knop-Framework-Discussion-f29076.html Project homepage http://montania.se/projects/knop/ Google Code has the latest downloads at http://code.google.com/p/knop/
Sep 19
Jason Huck Re: Trailing slashes in Knop
Sep 19, 2010; 15:27
Jason Huck
Re: Trailing slashes in Knop
Sep 19
Steve Piercy - Web Site Builder Re: Trailing slashes in Knop
Sep 19, 2010; 16:07
Steve Piercy - Web Site Builder
Re: Trailing slashes in Knop
Sep 20
Steve Piercy - Web Site Builder Re: Trailing slashes in Knop
Sep 20, 2010; 00:49
Steve Piercy - Web Site Builder
Re: Trailing slashes in Knop
Sep 20
Johan Solve Re: Trailing slashes in Knop
Sep 20, 2010; 08:55
Johan Solve
Re: Trailing slashes in Knop
Sep 21
Bil Corry Re: Trailing slashes in Knop
Sep 21, 2010; 21:09
Bil Corry
Re: Trailing slashes in Knop
Sep 22
Steve Piercy - Web Site Builder Re: Trailing slashes in Knop
Sep 22, 2010; 05:17
Steve Piercy - Web Site Builder
Re: Trailing slashes in Knop
Sep 22
Steve Piercy - Web Site Builder Re: Trailing slashes in Knop
Sep 22, 2010; 05:23
Steve Piercy - Web Site Builder
Re: Trailing slashes in Knop
Sep 22
Jason Huck Re: Trailing slashes in Knop
Sep 22, 2010; 06:31
Jason Huck
Re: Trailing slashes in Knop
Oct 03
Steve Piercy - Web Site Builder Re: Trailing slashes in Knop
Oct 03, 2010; 09:21
Steve Piercy - Web Site Builder
Re: Trailing slashes in Knop
Search
Lasso Programming
This site manages and broadcasts several email lists pertaining to Lasso Programming and technologies related and used by Lasso developers. Sign up today!