vimeo 如何路由它的 url?
我想知道 vimeo 如何使用路由来保留其参数,例如在 vimeo 中,搜索 uri 如下所示:
http://vimeo.com/videos/search:google/,在本例中将返回一个变量 google。
这很容易做到,只需在 php 中使用路由和爆炸即可将所需的数据放入有用的数组中,令我困惑的是他们如何设法使此网址正常工作:
http://vimeo.com/videos/search:go/ogle/,在我看来,路由器如何知道何时部分结束,vimeo 似乎能够将其读为“go/ogle”,但我看不出它如何区分新部分和现有部分之间的区别?为什么它不应该有两个键,一个作为搜索:另一个作为 ogle:?
希望这是有道理的
I'm wondering how vimeo manages to retain its parameters using routing, for example in vimeo, a search uri looks like this:
http://vimeo.com/videos/search:google/, which will return a variable in this case google.
This is easy enough to do, can simply use routes and explodes in php to get the data you require into a useful array, what foxes me is how they managed to get this url to work:
http://vimeo.com/videos/search:go/ogle/, in my mind how does the router know when the section ends, vimeo seems to be able to read it as "go/ogle" yet i cant see how it can tell the difference between a new section and and existing one? why shouldn't it have two keys one as search: the other as ogle:?
Hope this makes sense
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用
/
作为分隔符似乎没有那么严格。通过在 URL 上进行修改,我猜它会加载控制器videos
(如果我可以做出一些猜测)并使用search:
之后的任何内容作为搜索词。search:
之后似乎没有划分参数。It seems to be not so strict on using
/
as a delimiter. From tinkering with it on the URL I guess it loads the controllervideos
(if I can make some guesses) and uses anything aftersearch:
as the search term. Aftersearch:
it doesn't seem divide up parameters.对我来说,这看起来像是一个 cakePHP URL。
CakePHP PaginatorHelper 使用类似的格式对结果进行分页和对表数据进行排序,例如:
http://server.com/videos/page:1/sort:name
看一下这里并向后工作:
http://api.cakephp.org/view_source/paginator-helper/
That looks like a cakePHP URL to me.
The CakePHP PaginatorHelper uses a similar format for paging results and sorting table data, something like:
http: // server.com/videos/page:1/sort:name
Take a look here and work backwards:
http://api.cakephp.org/view_source/paginator-helper/