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 ._\/~%-+&#?!=()@:
Normally the desired URL can simply be copied and pasted from the address bar of your browser. If you are constructing the URL yourself for any reason, remember that certain reserved characters need to be percent coded. For example, ^ has to be written %5e, the hexadecimal ASCII value with a percent sign in front. A blank space within the title of Wikipedia article can also be converted into an underscore.
Higher Unicode characters can be included in URLs (like in internal links); the system will convert them as necessary. For example: http://meta.wikipedia.org/wiki/À_propos_de_Méta is equivalent to http://meta.wikipedia.org/wiki/%C3%80_propos_de_M%C3%A9ta .
For more details on how to make percent codes, see URLs in external links at Meta.
维基百科页面的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帮助页面。 中文维基中,可以使用“/zh/”(不转换)、“/zh-cn/”(大陆简体)、“/zh-tw/”(台湾正体)、“/zh-hk/”(港澳繁体)或“/zh-sg/”(马新简体)来实现繁简转换。
模板和编程
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.