-
-
Notifications
You must be signed in to change notification settings - Fork 363
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
Auto-redirect to canonical URLs #2
Comments
Original comment by Anonymous: After some discussion on cherrypy-devel, we're considering making this a configuration option. |
Original comment by sja (Bitbucket: sja, GitHub: sja): Should URIs with virtual path parameters have a trailing slash? My patch strips trailing slashes from such URLs, because I thought the most common case would be someting like /user/12, where "12" logically represents a file, or a leaf in the tree. But what should happen when we have urls such as /articles/2004/, which returns a list of articles from the given year? Is this an index/folder? Should it have a trailing slash? If so, how do we distinguish between the former and the latter case? Perhaps we could add a trailing slash when the list of parameters is incomplete. For example:
Given the previous method definition, these are the possible valid urls:
|
Original comment by sja (Bitbucket: sja, GitHub: sja): There are a couple open issues with my latest implementation.
In this case, b is a method, hence it will not have a trailing slash in the url (/a/b). But b allows a virtual path parameter (/a/b/45), so it's logically not a leaf, but an index... should it have a trailing slash when the parameter is unspecified?
If a method is defined as in this example, the URL of an article will have a trailing slash (/2004/12/5/3/), though it problably should not. A workaround is to define the method thus:
Personally I like this better because it creates a cleaner distinction between normal parameters and query string arguments. |
Originally reported by: Anonymous
The canonical URL scheme looks like this:
In other words, objects always have trailing slashes, methods never have trailing slashes.
CP2 should enforce this scheme by automatically doing an external redirect if the incoming request URI isn't "correct". For example, if the user requests /a, CP2 should redirect to /a/ before actually calling cpg.root.a.index().
If we do this, request handler classes can safely use relative HTML links to refer to their own (or their parent/child objects') methods.
See: http://sourceforge.net/mailarchive/message.php?msg_id=9558209
Reported by hmans
The text was updated successfully, but these errors were encountered: