Help:URL
如同万维网上的所有页面一样,维基媒体基金会服务器上的页面也有自己的URL(统一资源定位符)来区分它们。这些URL地址在您浏览页面时,显示在浏览器的地址栏中。维基百科编者也可以通过创建超链接至指定的URL,链接到维基百科或维基媒体基金会的其他计划页面,抑或是网络上的其他页面。
链接到URL
在编辑一个页面时,链接至维基百科(或其他维基媒体基金会计划)的超链接通常使用[[...]]语法建立“内部链接”或“跨语言链接”。但是如果你想要链接到外部站点上,或者是特殊生成的维基媒体页面(例如一个条目的历史版本),就有必要提供完整的URL地址了。这需要使用外部链接语法来实现。
有三种形式的外部链接语法:
- 如果直接在维基代码中输入URL地址,不加方括号,那么它就会原样呈现,并建立超链接:http://meta.wikimedia.org/的效果为 http://meta.wikimedia.org/
- 如果URL被放置在方括号内,就会产生一个带计数标签的超链接:[http://meta.wikimedia.org/]的效果为[1]
- 如果URL放置在方括号内,后面加上一个空格,并输入文本,那么后面的文本就会作为该超链接的标签:[http://meta.wikimedia.org/ Wikimedia]的效果为Wikimedia
想要隐藏箭头图标的话,请将外部链接置于 <span class="plainlinks">...</span>标签之间。
URL必须以“http://”、“https://”,“ftp://”或“irc://”。[1]另外URL中不能包含空格,而且必须只能包含下列字符,其他字符将自动转换为适当形式。
A-Z a-z 0-9 ._\/~%-+&#?!=()@:
通常您想使用的URL地址可以从浏览器的地址栏中复制粘贴古来。如果您因为某些原因需要自行输入地址,请注意部分保留字符需要使用UTF-8编码。例如,^ 要写做 %5e,为其[[十六进制]ASCII值并在前面加上百分号。维基百科条目标题中如果有空格,在地址中可以转换为下划线。
URL中还可以包含Unicode字符(同内部链接一样);系统会在必要时进行转换。例如:http://meta.wikipedia.org/wiki/À_propos_de_Méta 等同于 http://meta.wikipedia.org/wiki/%C3%80_propos_de_M%C3%A9ta 。
了解详情,参见元维基外部链接的URL一节。
维基百科页面的URL
中文维基百科的URL地址都以 http://zh.wikipedia.org/ 开头。此地址本身会重定向至Wikipedia:首页。
维基百科页面的URL地址有以下两种形式:
页面名有时可能包含名字空间前缀(例如本页的Help:)。一些Help:特殊页面可能会包含一个参数,例如 http://zh.wikipedia.org/wiki/Special:Contributions/Mountain (对于大多数特殊页面的参数,见下)。
Other URLs associated with a page are constructed by adding a query string. The string can be added to either of the above forms (as in http://en.wikipedia.org/wiki/Train?action=history ), but in this case the system defaults to the second form, i.e. it extends the index.php query string "title=Page_name".
Extended URLs are used:
- To go to a redirect page without following the redirect: http://en.wikipedia.org/w/index.php?title=Railway_train&redirect=no
- To go to the edit page (or view the source of a protected page): http://en.wikipedia.org/w/index.php?title=Train&action=edit. Other parameters can be added, such as section=5 or section=new to edit or add a page section. There are also parameters for preloading text into the edit box of a new page, as used by the inputbox extension (see mw:Extension:InputBox).
- To access the edit history of a page: http://en.wikipedia.org/w/index.php?title=Train&action=history (or further parameters can be added, as in http://en.wikipedia.org/w/index.php?title=Train&limit=5&offset=90&action=history, which displays edits 91–95).
- To link to a particular version of a page: http://en.wikipedia.org/w/index.php?title=Train&oldid=1374279 (this gives a permanent link to a particular version of the page). A permanent link to the present version of the page can be accessed by clicking "Permanent link" under "toolbox" on the left side of the page. Note that the version ID is unique across all pages, so the title parameter here has no effect, and can in fact be omitted.
- To link to a diff between two versions of a page: http://en.wikipedia.org/w/index.php?title=Train&diff=1374279&oldid=1260056 , where diff is the ID of the version to appear on the right. Set diff=0 to compare the current version; set diff=0 and oldid=0 to compare the two most recent versions. Again the title parameter has no real effect (you can in fact compare versions of two different pages).
- To watch or unwatch a page: http://en.wikipedia.org/w/index.php?title=Train&action=watch (or action=unwatch).
- To purge a page from the server cache (to have it rendered with the latest template versions etc.): http://en.wikipedia.org/w/index.php?title=Train&action=purge (this is not the same as purging your browser cache).
- To perform certain other defined actions, replacing purge in the above example with view, delete, revert, rollback, unprotect, info, markpatrolled, validate, render, deletetrackback (most of these are available only to administrators).
- To obtain the raw wikitext of a page without downloading the full HTML: http://en.wikipedia.org/w/index.php?title=Train&action=raw
- To view a category listing starting from a specified point: http://en.wikipedia.org/w/index.php?title=Category:Disambiguation_pages&from=B
- To specify parameters for a special page, as in: http://en.wikipedia.org/w/index.php?/w/index.php?title=Special:Recentchanges&from=20030918220000 (in this case the "from" parameter is a timestamp, format yyyymmddhhmmss, UTC time, but many other types of parameter are possible, depending on the page).
If constructing URLs for Wikipedia pages, remember to convert spaces into underscores, and to percent-code special characters where necessary, as described in the previous section. (For how to do this in template code, see Templates and programming below.)
Various kinds of error message may appear if an invalid URL, or one to which you do not have access, is submitted. In other cases the URL may redirect to a valid one (for example, page titles are converted to their canonical form as they are when they appear in wikilinks).
其他维基媒体计划的URL
除了域名不同外,其他计划也使用和中文维基类似的URL: http://meta.wikimedia.org/ (元维基)、 http://en.wikipedia.org/ (英文维基百科)、 http://de.wiktionary.org/ (德文维基字典)等。
注意,如果输入http://www.wikipedia.org,你将会转到一个多语言的维基百科专题页面,但是其他以此开头的URL都会重定向到英文维基。
其他计划可能使用不同的字符串来取代URL中的“/w/”或“/wiki/”。详情参见元维基上的URL帮助页面。
模板和编程
For use in templates, correct URLs can be constructed using certain magic words and parser functions such as fullurl, urlencode and others. Details of these can be found at mw:Help:Magic words.
Most programmatic interaction with Wikipedia can be performed most efficiently using the API, for which URLs beginning http://en.wikipedia.org/w/api.php are used. For details, see mw:API.
脚注
- ^ Note that URLs beginning "file://" do not work. This could be enabled (to work in MSIE only) by adding a $wgUrlProtocols entry to LocalSettings.php; see the $wgUrlProtocols in DefaultSettings.php for examples.