为什么某些网站网址不包含文件扩展名? [英] How come some site urls do not include a file extension?

查看:133
本文介绍了为什么某些网站网址不包含文件扩展名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在浏览互联网,发现例如YouTube,其中包含这样的URL来表示视频页面:http://www.youtube.com/watch?v=gwS1tGLB0vc.

I was browsing the internet and noticed, YouTube, for example, contains a URL like this to denote a video page: http://www.youtube.com/watch?v=gwS1tGLB0vc.

我的网站在主题页面上使用这样的URL:http://www.example.com/page.php?topic_id=6f3246d0sdf42c2jb67abba60ce33d5cc.

My site uses a URL like this for a topic page: http://www.example.com/page.php?topic_id=6f3246d0sdf42c2jb67abba60ce33d5cc.

区别在于,如果您尚未在youtube上注意到他们的观看页面没有文件扩展名,那么我想知道,为什么某些网站不使用文件扩展名以及它的用途是什么?

The difference is, if you haven't already noticed that on youtube, there is no file extension for their watch page, so I am wondering, why do some sites not use file extensions and what use does it serve?

推荐答案

不使用文件扩展名是因为URI(以及URL)应独立于实现,如果您想访问George W. Bush的地址,您应该可以访问 http://www.whitehouse.gov/presidents/georgewb​​ush/addresses (例如).白宫的服务器使用的是PHP还是Python,还是Perl对最终用户来说都无关紧要,因此他们不应该看到它.最终用户不在乎页面的生成方式,因为所有网络语言都输出相同的HTML,CSS等,并且他们只是在网络浏览器中查看页面.

File extensions are not used because of the idea that URIs (and therefore URLs) should be independent of implementation - if you want to access George W. Bush's addresses, you should be able to go to http://www.whitehouse.gov/presidents/georgewbush/addresses (for example). Whether the White House's servers are using PHP or Python or Perl doesn't matter to the end-user, so they shouldn't see it. The end-user doesn't care how the page was generated, because all web languages output the same HTML, CSS, and the like, and they're just viewing the page in their web browser.

大多数Web框架默认情况下都在默认情况下构建此功能,并且无论大多数Web服务器中是否进行URL重写,都可以实现该功能. W3C样式指南对此概念进行了编纂,毫无疑问,这种想法得到了广泛的接受,这是一个强烈的支持者.在他们的指南冷静的URI不变" 中对此进行了概述,如果您仍然不太了解这里的原因,请清理一下.该文档是该问题的首选声明,也是框架的事实上的标准.

Most web frameworks build this functionality in by default, precisely for this reason, and it can be accomplished regardless with URL rewriting in most webservers. This ideal is codified in the W3C Style Guide, which is undoubtedly a big proponent in this idea being so widely accepted. It's outlined in their guide, "Cool URIs Don't Change", which should clear things up if you still don't quite understand the reasoning here. That document is the go-to statement on the issue, and the de facto standard for frameworks.

值得注意的是,通常最终以下载格式下载的文件(有时是AJAX中使用的数据文件)仍会保留其文件扩展名- http://example.com/whitepaper.pdf -因为它们旨在保存到文件扩展名很重要的最终用户的计算机上.仅显示 的页面(大多数页面)不包含扩展名.

It is worth noting that usually files that end up being downloaded (and sometimes data files used in AJAX) will still have their file extensions intact - http://example.com/song.mp3 or http://example.com/whitepaper.pdf - because they are intended to be saved to the end-user's computer, where file extensions matter. The extensions are not included for pages that are simply displayed - which is most pages.

这篇关于为什么某些网站网址不包含文件扩展名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆