为什么维基百科没有扩展?

发布于 2024-10-11 07:56:33 字数 240 浏览 4 评论 0原文

随机查看维基百科文章,例如 http://en.wikipedia.org/wiki/Impostor_syndrome,我发现地址末尾没有附加 .html 。事实上,如果我尝试在其后面添加 .html,维基百科会告诉我“维基百科没有具有该确切名称的文章”。为什么它不需要任何文件扩展名?

Look at a random wikipedia article like http://en.wikipedia.org/wiki/Impostor_syndrome, I see that there's no .html attached to the end of the address. In fact, if I do try to put a .html after it, Wikipedia tells me "Wikipedia does not have an article with this exact name." How come it doesn't need any file extensions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

少年亿悲伤 2024-10-18 07:56:33

更多超级用户问题?

没有法律规定 html 文件必须以 .html 或 .htm 结尾,并且由于 wiki 从数据库生成页面,因此实际上没有文件页面(缓存中除外)。

没有 .htm 或 .php 更明智 - 当您请求 URL 时,为什么您关心他们使用什么技术?这就像必须将收件人的操作系统放在他们的电子邮件地址的末尾一样。

More a superuser question?

There is no law saying that an html file has to end in .html or .htm and since wiki generates pages from a database there is really no file page there anyway (except in a cache).

Not having .htm or .php is moresensible - why do you care what technology they use when you ask for a url? It would be like having to put the operating system of the recipient at the end of their email address.

哑剧 2024-10-18 07:56:33

如果您调用一个网站,它可能看起来像

www.example.com/siteA/index.html

此请求只是告诉网络服务器您想要查看 siteA 中名为 index.html 的资源。
在此服务器上运行的网站必须确定您想要查看的内容以及如何加载数据。
index.html 可以是 siteA 目录中的文件
或者
它可以是数据库中 siteA 表中带有键“index.html”的行。

所以 siteA/index.html 部分只是一个资源标识符。该资源标识符的语法是完全免费的,并且由每个网站确定。

url 重写也很常见,以使 url 更易于阅读和记住。

例如,可能有一个重写规则来完成以下任务:

如果用户输入类似的内容
www.example.com/download/demo.zip

重写它,以便您的网站显示如下:
www.example.com/download.php?file=demo.zip

if you make a call to a website it probably looks like

www.example.com/siteA/index.html

this request just tells the webserver you want to see a resource that is called index.html in siteA.
the website that runs on this server has to determine what you want to see and how the data is loaded.
index.html could be a file in the siteA directory
or
it can be row with the key "index.html" in the siteA-table in your database.

so the part siteA/index.html is just a resource identifier. the grammar of this resource identifier is completely free and is determined per website.

url rewriting is also common to make url easier to read and remember.

for example there could be a rewrite rule to accomplish the following:

if the user enters something like
www.example.com/download/demo.zip

rewrite it so your website sees it like:
www.example.com/download.php?file=demo.zip

挽清梦 2024-10-18 07:56:33

维基百科的服务器将 URL 映射到您想要的页面。 .html 只是一种命名约定,今天主要是从静态页面时期开始的,当时 url 实际上是服务器上文件的名称。事实上,可能根本没有文件,服务器查询数据库,Web 框架动态发送 html。

Wikipedia's servers map the url to the page you want. .html is just a naming convention that, today is mostly historical from the period of static pages when urls actually were names of files on the server. In fact, there may be no file at all, where the server queries the database and a web framework sends out the html on the fly.

牵强ㄟ 2024-10-18 07:56:33

维基百科很可能使用 Apache 模块 mod_rewrite ,以便不必将路径直接链接到文件系统路径。

请参阅:http://en.wikipedia.org/wiki/Rewrite_engine#Web_frameworks

但是编程语言还可以控制传入的 URL 并根据某些规则集根据链接的结构返回数据,例如 Django Web 框架员工 URL 调度程序

Wikipedia is most likely using the Apache module mod_rewrite in order to not have to link paths directly to a file system path.

See: http://en.wikipedia.org/wiki/Rewrite_engine#Web_frameworks

However programming languages can also take control of the incoming URLs and return data depending on the structure of the link according to some set of rules, for example the Django web framework employees a URL dispatcher.

沉睡月亮 2024-10-18 07:56:33

这是因为 Wikipedia 使用了 MediaWiki 的 URL 缩短功能。

实际上,当你搜索一个文件时,它实际上会加载一个 php 文件。尝试搜索不存在的单词,例如“Pazaz”。网址为 http://en.wikipedia.org/w/index.php?title=Special%3ASearch&search=pazaz 。请注意 URL 中的 index.php

说实话,这不是 MediaWiki 的功能,而是 Apache 的功能。如需了解更多信息,请http://www.mediawiki.org/wiki/Manual:Short_URL

That's because Wikipedia uses MediaWiki's feature of URL shortening.

Actually when you search for a file it really loads a php file. Try searching for a word that doesn't exist, for example "Pazaz". The URL is http://en.wikipedia.org/w/index.php?title=Special%3ASearch&search=pazaz . Notice index.php in the URL.

To tell the truth it's not a MediaWiki feature, it's Apache. For further info http://www.mediawiki.org/wiki/Manual:Short_URL .

昵称有卵用 2024-10-18 07:56:33

URL 路由是您的答案,例如在 ASP 中阅读下面来源

ASP.NET MVC 框架包含一个灵活的 URL 路由系统,使您能够在应用程序中定义 URL 映射规则。路由系统有两个主要目的:

  1. 将传入 URL 映射到应用程序并路由它们,以便执行正确的控制器和操作方法来处理它们
  2. 构造可用于回调控制器/操作的传出 URL(例如:表单帖子、链接和 AJAX 调用)

URL routing is your answer for example in ASP read below source from

The ASP.NET MVC framework includes a flexible URL routing system that enables you to define URL mapping rules within your applications. The routing system has two main purposes:

  1. Map incoming URLs to the application and route them so that the right Controller and Action method executes to process them
  2. Construct outgoing URLs that can be used to call back to Controllers/Actions (for example: form posts, links, and AJAX calls)
坦然微笑 2024-10-18 07:56:33

我建议像这样的网站使用某种类似于 Ruby on Rails 的模型视图控制器框架,其中 url 'directories'形成请求/url 路由的一部分...

在基于 MVC 的框架中,url“目录”可以指示要使用的视图/控制器以及应对数据采取什么操作。

例如:shop.com/product/carrots

其中,product 是视图/控制器,carrots 是数据。然后该框架分析要采取的行动/路线。默认可以查看胡萝卜的产品信息和价格。

I would suggest that sites like this use some sort of Model View Controller framework similar to Ruby on Rails where the url 'directories' form a part of a request/url route...

In frameworks that are MVC based, the url 'directories' can dictate what View/Controller to utilise as well as what action should be taken with the data.

eg: shop.com/product/carrots

Where product is a view/controller and carrots is the data. The framework then analyses which action/route to take. Default could be viewing the product information and price of the carrot.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文