m robot Adding: de, eo, fa, fr, it, nl, pt, vi |
ToadetteEdit (talk | contribs) →Creating and editing redirects: update Tags: Mobile edit Mobile web edit Advanced mobile edit |
||
(518 intermediate revisions by more than 100 users not shown) | |||
Line 1: | Line 1: | ||
{{short description|Wikimedia help page}} |
|||
{{H:h|editor toc}} |
|||
{{pp-semi-indef|small=yes}} |
|||
:''See also: [[w:Wikipedia:Redirect|Wikipedia:Redirect]]'' |
|||
{{about|directing a search term to a Wikipedia article|clarifying redirected search terms at the article itself|Template:Redirect|guidance on the use of redirects|Wikipedia:Redirect}} |
|||
{{Wikipedia how-to|H:R|H:REDIR}} |
|||
A '''redirect''' is a page created so that navigation to a given title takes the reader directly to a different page. A redirect is created using the syntax: |
|||
<syntaxhighlight lang="wikitext"> |
|||
#REDIRECT [[Target]] |
|||
</syntaxhighlight> |
|||
...where "target" is the name of the target page. It is also possible to add a [[WP:section|section]] header to make a redirect to a specific section of the target page in the following manner: |
|||
<syntaxhighlight lang="wikitext"> |
|||
#REDIRECT [[Target#Section header]] |
|||
</syntaxhighlight> |
|||
The pound/number/hash sign (#) is also used to link to [[WP:anchor|page anchors]]. |
|||
Usually, [[WP:RCAT|redirect maintenance categories]] should also be added. |
|||
A redirect is a page starting with: |
|||
==Syntax== |
|||
<nowiki>#Redirect [[</nowiki>''PMI-SP''<nowiki>]] {{R to other namespace}} </nowiki> |
|||
{{Shortcut|Wikipedia:Hard redirect}} |
|||
A page is treated as a redirect page if its [[WP:wikitext|wikitext]] begins with <code>#REDIRECT</code> followed by a valid [[Help:Link|wikilink]] or [[Help:Interwiki|interwikilink]]. A space is usually left before the link. (Note that some alternative capitalizations of "REDIRECT" are possible.) |
|||
Note that a redirect works as intended (takes the reader directly to the target page) only if the link is to an existing normal page (not a [[Help:special page|special page]]) on the same project (English Wikipedia). In other cases soft redirects are often used – see [[#Soft redirects|below]]. |
|||
where ''PMI-SP'' is the target page. |
|||
Examples: |
|||
Extra text after the #REDIRECT command and link is ignored. It is rendered only in preview and in a diff. |
|||
* <code><nowiki>#REDIRECT [[France]]</nowiki></code> (redirects to the [[France]] article) |
|||
* <code><nowiki>#REDIRECT [[France#History]]</nowiki></code> (redirects to the "History" section of the [[France]] article) |
|||
* <code><nowiki>#REDIRECT [[fr:France]]</nowiki></code> (appears as a redirect to the [[France]] article on French Wikipedia, but does not work as a true redirect) |
|||
Any text appearing after the redirect link is ignored in the display, but may be used to add categories, interwiki links, comments, etc. |
|||
Note that the redirect link must be explicit – it cannot contain [[Help:Magic word|magic words]], [[WP:template|templates]], etc. |
|||
When redirecting to a [[Help:category|category]] page, prefix the target pagename with a colon to prevent the redirect from showing up in the category. (Redirects from one category page to another should use soft redirects – see [[#Soft redirects|below]].) Redirects to [[Help:image|image]] pages also require the colon. |
|||
==How it appears to the user== |
==How it appears to the user== |
||
If the redirect target is an existing page |
If the redirect target is an existing page on English Wikipedia and a reader navigates to the redirect page – by [[Help:Link|wikilink]], the search box, or a [[Help:URL|URL]] – the reader is taken directly to the target page. A small notice below the top title indicates that the user arrived via a redirect. For example, if you click [[Transportation]], you are redirected to the [[Transport]] article, and the top of the page looks like: |
||
For example, if somebody goes to [[Help:Redirection]], then they will end up at this page instead, and the top of the page will look like: |
|||
<blockquote style="background-color: white; color: black; border:1px solid black; padding: 1em;"> |
<blockquote style="background-color: white; color: black; border:1px solid black; padding: 1em;"> |
||
{{fake heading|Transport}} |
|||
<h1 class="firstHeading">Help:Redirect<h1> |
|||
From Wikipedia, the free encyclopedia |
|||
{{Indent|3}}<small>(Redirected from <span class="plainlinks">[{{fullurl:Transportation|redirect=no}} Transportation]</span>)</small> |
|||
<div id="contentSub">(Redirected from [[Help:Redirection]])</div> |
|||
</blockquote> |
</blockquote> |
||
To |
To go to the redirect page itself (to edit it, view its history, etc.), click the link in the "(Redirected from...)" notice. |
||
If the redirect target is a non-existing page |
If the redirect target is a non-existing page ([[WP:redlink|redlink]]), or a [[Help:special page|special page]], or a page in another project, then the redirect is not followed, and the reader sees the display of the redirect page (as illustrated below). If the target is a non-existent section of an existing page, then the redirect will take the reader to the top of the target page. |
||
Chains of redirects are not followed. If title ''A'' redirects to ''B'', and ''B'' is itself a redirect page, then a reader navigating to ''A'' will see the display of the redirect page ''B'' (as illustrated). See [[WP:Double redirects|Double redirects]]. ([[Help:Bot|Bots]] fix such chains so that each redirect points directly to the final target page.) |
|||
When a page called for inclusion is a redirect page, the redirect target is included instead, with the same parameters, without any redirect message. A double redirect does not work (see below). |
|||
A redirect page viewed directly, either in the situations described above, or when the [[Help:URL|URL]] used to access the page contains the query parameter <code>redirect=no</code>, looks like this: |
|||
==Restrictions== |
|||
As a simple way to avoid problems with infinite [[w:Recursion|recursion]], if the redirect target is another redirect page, the second redirect is not applied. |
|||
A redirect target cannot depend on a variable, template, or parser function. When attempting this, the restriction does not become apparent in the preview (see also the section below on the rendering of a redirect page), but only after saving. |
|||
A code like %70 in a redirect disables it, although the link works from the redirect page. |
|||
Note also that different projects have different specifications on ''what'' can be redirected. On en.wiktionary.org, the multilingual dictionary, most redirects are prohibited by policy. |
|||
==Purposes of a redirect== |
|||
* Allow access in the case that a pagename is provided: |
|||
** which is an alternative term for the subject |
|||
** which is a term for a subtopic (in this case one may use a redirect to a section) |
|||
** which uses alternative capitalization and hyphenation |
|||
** which uses alternative spelling |
|||
** which has a common misspelling |
|||
* Provide a way of conveniently going to a page (shortcut). |
|||
* Keep links to a page active after it has been moved (even if internal links are updated, this still applies for links from outside; also for [[Help:Edit summary#Internal and interwiki links in edit summaries|links in edit summaries]]). |
|||
=== Special purposes === |
|||
*Conveniently linking indirectly to a page, without the need for a [[Help:Piped link|Piped link]]. However, a piped link is in some respects even better than relying on a redirect, see [[Help:Piped link#Using a redirect as an alternative|Comparison with piped link]]. |
|||
*Allowing a link title independent of the final link target; one creates a page whose name is the desired link title, and which redirects to the desired target page. See e.g. [[w:Template:Ft]], containing <nowiki>[[30.48 cm|ft]]</nowiki>, with the page [[w:30.48 cm]] redirecting to [[w:Foot (unit of length)]]. The link title "30.48 cm" informs in the hover box about the unit "ft" even without following the link to the article about this unit. See also [[Help:Advanced_editing]] for another technique with a similar result. |
|||
When creating new redirects, bear in mind that creating too many redirects can clutter up the [[Help:Searching|search results page]], which can hinder users. Also, don't spend too much time creating redirects - often it's more important to spend time improving the quality of the target page. A [[Help:Piped link|piped link]] is another way to make a link to a page with a name which does not occur in the first page. |
|||
==Creating a redirect== |
|||
If you're creating a new redirect, [[Help:Starting a new page|start a new page]], write <nowiki>#Redirect [[pagename]] {{R to other namespace}} </nowiki> (or <nowiki>#redirect [[pagename]]</nowiki>) at the top of the page, where ''pagename'' is the name of the target page. Here is [http://meta.wikipedia.org/w/wiki.phtml?title=redirection&action=edit&redirect=no an example]. If you're replacing an existing page with a redirect, for example after merging a duplicate page, go to the page, edit it, and replace the existing text with <nowiki>#REDIRECT [[pagename]]</nowiki>. |
|||
The page will not redirect if there is anything on the page ''before'' the redirect. Also, there must be no spaces between the # and the REDIRECT. |
|||
Extra text ''after'' the #REDIRECT command and link is ignored. It is rendered only in preview and in a diff, see [http://meta.wikimedia.org/w/index.php?title=Talk:MediaWiki_User%27s_Guide:_Using_redirects&action=edit], [http://meta.wikimedia.org/w/index.php?title=Talk:MediaWiki_User%27s_Guide:_Using_redirects&diff=356885&oldid=356884], and [http://meta.wikimedia.org/w/index.php?title=Talk:MediaWiki_User%27s_Guide:_Using_redirects&redirect=no]. Category-tags are not ignored. If a category is set, the redirect-page is listed in the category it belongs to. When following the link from the category page to the redirect page then as usual the redirect is ''applied''. |
|||
An [[Help:Edit summary|edit summary]] is automatically provided, with the text according to [[MediaWiki:Autoredircomment]], but only if no edit summary is supplied (as opposed to the automatic edit summary in section editing, which can be supplemented by the user). |
|||
==Rendering of the redirect page== |
|||
After you save the redirect page, you get sent to a page with the string "&redirect=no" in the URL. Thus the just created redirect page is shown, not the page to which it redirects. The redirect page should look something like: |
|||
<blockquote style="background-color: white; color: black; border:1px solid black; padding: 1em;"> |
<blockquote style="background-color: white; color: black; border:1px solid black; padding: 1em;"> |
||
{{fake heading|Transportation}} |
|||
<h1 class="firstHeading">Help:Redirection<h1> |
|||
<small>From Wikipedia, the free encyclopedia</small> |
|||
<h3 id="siteSub">From {{ns:project}}<h3> |
|||
<div |
<div>Redirect page</div> |
||
[[ |
[[File:Redirect arrow without text.svg]] <span class="redirectText">[[Transport]]</span> |
||
</blockquote> |
</blockquote> |
||
(See the actual {{no redirect|Transportation}} redirect page.) |
|||
After the page title, the content of [[MediaWiki:Redirectpagesub]] (by default the text "Redirect page"), a bent arrow, and the link to the redirect target is rendered. This link shows the canonical form of the target. As mentioned above, the text after the link to the redirect target is ignored, except for category tags. |
|||
Redirects to articles that begin with a lowercase title, for example the redirect from the page at [https://en.wikipedia.org/w/index.php?title=EBay.com&redirect=no Ebay.com] to the article at [[eBay]], will display the target page with a capitalized first letter, even though the article displays the title with a lowercase title. This is because the true title of the target page is actually capitalized — it just appears lowercase because of the use of the magic word [[Help:Magic words#Behavior switches|DISPLAYTITLE]]. (Usually, the template <nowiki>{{</nowiki>[[Template:Lowercase title|Lowercase title]]<nowiki>}}</nowiki> is used to implement the DISPLAYTITLE magic word for lowercase titles.) |
|||
This does not apply in the {{ml|help:preview||preview}} of a redirect page: this ignores the special meaning of the redirect syntax, so it shows a one-item numbered list, with the link rendered as an ordinary link, and followed by the extra content. Compare [http://meta.wikimedia.org/w/index.php?title=Babel&redirect=no] with the preview of its edit page [http://meta.wikimedia.org/w/index.php?title=Babel&action=edit]. |
|||
===Section redirects=== |
|||
To see your redirect working, use your address bar to delete that part of the URL. Alternatively, create a link on another page to your redirect, and then follow that link. |
|||
When the redirect target is a [[Help:section link|section link]], following a redirected link should lead to the section or other element identified by the link. Normally the redirected page includes the entire contents of the target page as if the section fragment wasn't specified, and uses [[JavaScript]] to jump to the section after the page is loaded. If JavaScript is disabled, this jump does not happen. |
|||
When a redirect page is viewed directly without following the target link, the link is shown as an ordinary section link, and works as usual without the use of JavaScript. |
|||
==Changing a redirect== |
|||
When changing a redirect target to a different page, or turn a redirect page into a regular page, you must go to the redirect page. To do so, click on a link to the redirect page. Then look for the link to the redirect page at the top of the page you've been redirected to; e.g. |
|||
<div id="contentSub">(Redirected from [[Help:Redirection]])</div> |
|||
==Purposes of a redirect== |
|||
Once you get to the redirect page, click '''Edit this page'''. You can then either change the target of the redirect, replace the redirect with a brand new page or revert to an earlier version of the article, before it became a redirect. |
|||
{{detail|Wikipedia:Redirect#Purposes of redirects}} |
|||
Redirects are usually created because readers may search for an article under different names (or editors may wish to link to it from different names). Examples are: |
|||
* Alternative names for the same thing |
|||
* Alternative spellings, capitalizations, etc. (although it is not necessary to create redirects from different capitalizations just because readers may enter them in the search box - the Go button in the Monobook skin resolves this automatically) |
|||
* Common misspellings |
|||
* Plurals |
|||
* Subtopics that don't have their own article (in this case, you may redirect to a section of the target page) |
|||
* [[WP:Shortcut|Shortcuts]] to a page, used mainly in project space (such as [[WP:AFD]]) |
|||
* Redirects that keep links to a page active after it has been renamed (even if internal links are updated—this still applies for links from outside and [[Help:Edit summary#Internal and interwiki links in edit summaries|links in edit summaries]]) |
|||
Note that it is not necessary to create redirects from every title an editor may conceivably wish to link to a given page – [[Help:Piped link|piped links]] can be used as an alternative. |
|||
Another way to get to the redirect page: Go to the target page, and click "What links here". This will show you all the back-links from that page, including redirects. To change a redirect, click on it, and then click on '''Edit this page''' as above. |
|||
==Creating and editing redirects== |
|||
== Deleting a redirect == |
|||
:''Unregistered users, and those not yet [[Wikipedia:User access levels#Autoconfirmed and confirmed users|autoconfirmed]], can request a redirect be created at [[Wikipedia:Articles for creation/Redirects]]. There is also a [[Wikipedia:Article_wizard/Redirects|wizard]] that less experienced editors can use to create a redirect.'' |
|||
[[Meta:Administrators|Administrators]] can [[w:Wikipedia:Deletion policy|delete]] redirects in the same way as any other page. There may be project-specific guidelines on when this is appropriate. |
|||
A redirect page can be created like any other page (see [[Help:Creating a new page|Creating a new page]]). Simply type in the wikitext <code><nowiki>#REDIRECT [[</nowiki>xxx]]</code>, replacing "xxx" with the title of the target page (optionally followed by a "#" sign and the section title). |
|||
== The moving function == |
|||
When a page is renamed/moved with the [[Help:Moving a page|moving]] function, a redirect is automatically created from the old to the new name, and also one for the corresponding talk page. |
|||
Make sure that there is no text ''before'' the #REDIRECT keyword, or the redirect will not work. There is not usually any reason to place any text after the link either, although sometimes categories (or categorizing templates—see [[WP:Categorizing redirects|Categorizing redirects]]), interwiki links (see [[WP:Interlanguage links|Interlanguage links]]) or HTML comments (<code><nowiki><!-- comment --></nowiki></code>) are added. |
|||
If the new page name is occupied by a redirect that has only one edit in its history and targeted to the old page name, it is replaced by the page being moved. If the redirect has more than one history entry, or the redirect target is somewhere else, then it must be moved by an administrator. |
|||
Similarly, any existing page can be edited to turn it into a redirect. |
|||
To edit a page that is already a redirect (or to view its history, talk page, etc.), follow the redirect to the target page, then click on the link in the "(Redirected from ...)" notice at the top of the page. This takes you to the redirect page itself. (The [[Help:URL|URL]] for accessing a redirect page without following the redirect contains the query parameter ''redirect=no''.) |
|||
== Redirect to special targets == |
|||
=== Interwiki redirects and redirects to special pages=== |
|||
Another way to get to a redirect page is to go to the target page, and click "[[Help:What links here|What links here]]" (in the toolbox on the left of the page). This will show you all the [[backlink]]s to that page, including redirects. Clicking on a redirect in this list will take you to the redirect page, not the target. |
|||
Interwiki redirects and redirects to special pages have been disabled, try e.g. [[Help:Interwiki redirect demo]] and [[Help:Redirect to special page demo]]. |
|||
The [[Help:edit summary|edit summary]] box can be left blank; the summary will then be automatically generated stating that the page has been redirected to the given target. (This applies for: a new redirect page; an existing article page turned into a redirect page; and a change to the target of an existing redirect.) The generated summary is overridden if the editor supplies their own summary. |
|||
Use direct [[Help:Interwiki linking|interwiki link]]s (or direct links to Special pages) without redirect, or a [[w:Wikipedia:Soft redirect|soft redirect]] (non-automatic). |
|||
=== |
=== Using VisualEditor === |
||
To create a redirect using the [[Wikipedia:VisualEditor|VisualEditor]]: |
|||
One may redirect to an anchor, in particular a section. [[Help:Section linking and redirects]] is an example and its target also provides more info ('''it does not work for every environment'''). |
|||
# Open the "page options" menu (icon with three parallel horizontal bars) at the top right of the editor |
|||
# Select "Page settings" |
|||
# Check the box marked "Redirect this page to" |
|||
# Enter the name of the target page in the text box below the checkbox |
|||
# Click on the blue "Apply changes" button |
|||
# Save the page. You may enter an edit summary, or an automatic summary will be generated. |
|||
===With Template=== |
|||
Section redirects are supposed to work from r18220 onwards. See [[bugzilla:218]]. If it does not work, you will be redirected to the page but you will not be sent to the section. |
|||
For redirecting ''xyz'' to article ''abc'', enter ''xyz'' here, and type <nowiki>#REDIRECT [[abc]]</nowiki> in the body. |
|||
=== A redirect to a page in the image or category namespace === |
|||
On Meta and Wikipedia a redirect to an image page or to a category shows the editable text only. To get the full page after being redirected, use the link "Image", or "Category", respectively. |
|||
<div style="float: left"><inputbox> |
|||
On Commons a redirect to a category gives the full page, but not the subcategories and pages in the redirect page (if that is also a category). |
|||
type=create |
|||
align=left |
|||
preload=Template:Redirect preload |
|||
editintro=Template:Redirect editintro |
|||
buttonlabel=Create redirect |
|||
break=no |
|||
</inputbox></div><div style="clear: both" ></div> |
|||
== Deleting redirects == |
|||
To prevent a page that redirects to a category from appearing in the category; precede the word Category with a colon like so : <nowiki>#Redirect [[:Category:Glossary]] {{R to other namespace}} </nowiki> |
|||
{{see also|Wikipedia:Redirect/Deletion reasons}} |
|||
[[WP:Administrator|Administrators]] can delete redirects in the same way as any other page. Deletion or other potentially controversial treatment of redirects can be proposed by any editor at [[WP:Redirects for discussion|Redirects for discussion]]. Please refer to Wikipedia's [[WP:deletion policy|deletion policy]] for details and instructions. |
|||
==Moving pages== |
|||
===Images linking to a specific page=== |
|||
When a page is [[Help:Moving a page|moved]] (renamed), a redirect is automatically created from the old to the new name, and also one for the corresponding talk page (if that was moved as well). [[WP:Administrator|Administrators]] and [[WP:PGM|page movers]] can choose to [[Wikipedia:Redirect#Suppressing redirects|suppress]] creation of the redirect. |
|||
There are ways to make an image link to a specified page, some which work especially well on Mediawiki sites that support embedding external images. For possibilities see [[Help:Navigational image]]. |
|||
If the new page name is occupied by a redirect that has only one edit in its history and targeted to the old page name, it is replaced by the page being moved. If the redirect has more than one history entry, or has a different target page, then the move must be made by an administrator or pagemover. |
|||
==CSS class== |
|||
==Transclusion== |
|||
With the new preprocessor an internal link to a redirect page has CSS class "mw-redirect". This can be useful to make them stand out, for clean-up work involving bypassing redirects. |
|||
When a page called for [[WP:transclusion|transclusion]] is a redirect page, the redirect target is included instead, with the same parameters, without any redirect message. Hence if [[Template:AFD]] is redirected to [[Template:Afd]], then <code><nowiki>{{AFD|...}}</nowiki></code> will have the same effect as <code><nowiki>{{Afd|...}}</nowiki></code> As usual, [[WP:double redirects|double redirects]] are not followed. |
|||
==Soft redirects== |
|||
==Redirect and/or link to non-existing page== |
|||
As an alternative to the normal "hard" redirects (which take the reader directly to the target page), it is possible to create [[Wikipedia:Soft redirect|"soft" redirects]], which leave the reader on the redirect page, giving them the option of clicking the link to the target page. This is usually done in the following situations: |
|||
When B is a subtopic of A, and B does not have its own page, or at least not with additional info, there are the following possibilities: |
|||
* When the target is on another project ([[Wiktionary]], [[MetaWiki|Meta]], other language Wikipedias, etc.) or is a [[Help:special page|special page]]. (In these situations a hard redirect would behave as a soft one in any case.) |
|||
* For [[Help:Category#Moving and redirecting category pages|redirects between categories]]. (Hard redirects work for category pages, but soft ones are preferred because of the software's inability to recategorize pages from redirected categories.) |
|||
Soft redirects are created using the templates {{tl|soft redirect}} and {{tl|category redirect}}. |
|||
#redirect B to A, use the backlink to go from A to B (disadvantage: not very inviting to create a new content page B; inconvenient if A has many backlinks) |
|||
#link A to B ("[[w:Wikipedia:Red link|red link]]") as invitation or preparation for creating page B; use the backlink to go from B to A (disadvantage: not obvious for newbie, much less convenient than automatic redirect, especially if B has many backlinks) |
|||
#both (indirect self-link on A). To go from A to B, click the link from A to B, which brings you back to A, and use the link in the redirect message (for detecting a redirect see above; however, there is no distinction between a redirect back, and an onward redirect) (disadvantage, as far as not yet mentioned: not obvious for newbie) |
|||
#ditto but with a [[w:Wikipedia:soft redirect|soft redirect]] from B to A, i.e. a page only containing something like "See <nowiki>[[</nowiki>A]]"; one can see at A that B is very short using the [[Help:Link#Stub_feature|stub feature]] (disadvantages: a soft redirect is non-standard; people who do not know about its reason may change it in a regular redirect; is a little less convenient than automatic redirect; requires stub feature setting) |
|||
#B is a redirect, link from A to B with "redirect=no", or link to B's edit page, e.g. [http://meta.wikimedia.org/w/index.php?title=Template&redirect=no Template] and [http://meta.wikimedia.org/w/wiki.phtml?title=Template&action=edit start page Template], respectively. |
|||
In the 3rd and 4th case, especially if A has a list of links to pages B, one can mark the links with more info, e.g. by bolding, and explain the marking. |
|||
==Force all redirects to be client side redirects (HTTP 302 Temporary Redirect)== |
|||
(for MediaWiki 1.9.0) |
|||
(modified code by Uriah Anthony Stephenson-Ward | [mailto:uriah@diyinfo.org uriah@diyinfo.org] | [http://www.diyinfo.org DIYinfo.org]) |
|||
;What?: This piece of code forces all redirects to be done by the client, by issuing them a 302 Temporary Redirect to the new pages specific location. |
|||
;Why?: A lot of search engines decrease your pages rank if they discover duplicated content. The traditional Redirect method allows a huge amount of duplication, and doesn't redirect as nicely. This also allows you to use images for navigation. Additionally it can be a limitation/annoying to not see the full redirected pages location in the address bar, and having the annoying "Redirected from" link. |
|||
:'''Warning: This hack will increase your servers network load somewhat, for 99% of MediaWiki servers this will be negligible, but I wouldn't see Wikipedia doing this mod any time soon!''' |
|||
;How?: Open ''"includes\Article.php"'' and edit the function ''"followRedirect()"'' |
|||
:Change line 94 (approximately) from ''"return $rt;"'' to ''"return $rt->getFullURL();"'' |
|||
:The whole function should now look like this: |
|||
<pre> |
|||
<nowiki> |
|||
/** |
|||
* @return mixed false, Title of in-wiki target, or string with URL |
|||
*/ |
|||
function followRedirect() { |
|||
$text = $this->getContent(); |
|||
$rt = Title::newFromRedirect( $text ); |
|||
# process if title object is valid and not special:userlogout |
|||
if( $rt ) { |
|||
if( $rt->getInterwiki() != '' ) { |
|||
if( $rt->isLocal() ) { |
|||
// Offsite wikis need an HTTP redirect. |
|||
// |
|||
// This can be hard to reverse and may produce loops, |
|||
// so they may be disabled in the site configuration. |
|||
$source = $this->mTitle->getFullURL( 'redirect=no' ); |
|||
return $rt->getFullURL( 'rdfrom=' . urlencode( $source ) ); |
|||
} |
|||
} else { |
|||
if( $rt->getNamespace() == NS_SPECIAL ) { |
|||
// Gotta handle redirects to special pages differently: |
|||
// Fill the HTTP response "Location" header and ignore |
|||
// the rest of the page we're on. |
|||
// |
|||
// This can be hard to reverse, so they may be disabled. |
|||
if( $rt->isSpecial( 'Userlogout' ) ) { |
|||
// rolleyes |
|||
} else { |
|||
return $rt->getFullURL(); |
|||
} |
|||
} |
|||
return $rt->getFullURL(); |
|||
} |
|||
} |
|||
// No or invalid redirect |
|||
return false; |
|||
} |
|||
</nowiki> |
|||
</pre> |
|||
==See also== |
==See also== |
||
{{Wikipedia glossary}} |
|||
*[[Help:Link#Stub_feature|Detecting links to redirects using the stub feature]]. |
|||
* [[:Category:Redirect templates]] |
|||
*[[m:Redirects in search results - proposed software changes|Redirects in search results - proposed software changes]]. |
|||
* [[WP:HAT|Hatnote]] and [[Wikipedia:HATTEST#Redirect|examples]] for page hatnotes |
|||
*[[m:Redirected user pages considered harmful|Redirected user pages considered harmful]] |
|||
*[[ |
* [[meta:Help:Redirect|Redirect technical help at Meta-Wiki]] |
||
* [[Wikipedia:Printability]] |
|||
**[[Wikipedia:Redirects_for_deletion#When_should_we_delete_a_redirect.3F|Deletion policy on Wikipedia for redirects]] |
|||
* [[Wikipedia:Template messages/Redirect pages]] |
|||
* WikiProject Redirect's [[Wikipedia:WikiProject_Redirect/Style_guide|style guide]] |
|||
{{H:f|langs=|enname=Redirect}} |
|||
* [[Wikipedia:Visualizing redirects]], for how to make links to redirects stand out (based on the <code>mw-redirect</code> CSS class) |
|||
{{Help navigation}} |
|||
[[ca:Ajuda:Redirecció]] |
|||
{{Wikipedia technical help|collapsed}} |
|||
[[de:Hilfe:Weiterleitung]] |
|||
[[Category:Wikipedia article title help|Redirect]] |
|||
[[eo:Helpo:Plusendilo]] |
|||
[[Category:Wikipedia redirecting| ]] |
|||
[[fa:راهنما:تغییر مسیر]] |
|||
[[Category:Wikipedia features|Redirect]] |
|||
[[fr:Aide:Redirection]] |
|||
[[ |
[[Category:Wikipedia page help|Redirect]] |
||
[[nl:Help:Redirect]] |
|||
[[km:ជំនួយ:ការប្តូរទីតាំងទំព័រ]] |
|||
[[pt:Ajuda:Guia de edição/Redireccionar páginas]] |
|||
[[vi:Trợ giúp:Đổi hướng]] |
Latest revision as of 00:53, 29 May 2024
A redirect is a page created so that navigation to a given title takes the reader directly to a different page. A redirect is created using the syntax:
#REDIRECT [[Target]]
...where "target" is the name of the target page. It is also possible to add a section header to make a redirect to a specific section of the target page in the following manner:
#REDIRECT [[Target#Section header]]
The pound/number/hash sign (#) is also used to link to page anchors.
Usually, redirect maintenance categories should also be added.
Syntax
A page is treated as a redirect page if its wikitext begins with #REDIRECT
followed by a valid wikilink or interwikilink. A space is usually left before the link. (Note that some alternative capitalizations of "REDIRECT" are possible.)
Note that a redirect works as intended (takes the reader directly to the target page) only if the link is to an existing normal page (not a special page) on the same project (English Wikipedia). In other cases soft redirects are often used – see below.
Examples:
#REDIRECT [[France]]
(redirects to the France article)#REDIRECT [[France#History]]
(redirects to the "History" section of the France article)#REDIRECT [[fr:France]]
(appears as a redirect to the France article on French Wikipedia, but does not work as a true redirect)
Any text appearing after the redirect link is ignored in the display, but may be used to add categories, interwiki links, comments, etc.
Note that the redirect link must be explicit – it cannot contain magic words, templates, etc.
When redirecting to a category page, prefix the target pagename with a colon to prevent the redirect from showing up in the category. (Redirects from one category page to another should use soft redirects – see below.) Redirects to image pages also require the colon.
How it appears to the user
If the redirect target is an existing page on English Wikipedia and a reader navigates to the redirect page – by wikilink, the search box, or a URL – the reader is taken directly to the target page. A small notice below the top title indicates that the user arrived via a redirect. For example, if you click Transportation, you are redirected to the Transport article, and the top of the page looks like:
From Wikipedia, the free encyclopedia
(Redirected from Transportation)
To go to the redirect page itself (to edit it, view its history, etc.), click the link in the "(Redirected from...)" notice.
If the redirect target is a non-existing page (redlink), or a special page, or a page in another project, then the redirect is not followed, and the reader sees the display of the redirect page (as illustrated below). If the target is a non-existent section of an existing page, then the redirect will take the reader to the top of the target page.
Chains of redirects are not followed. If title A redirects to B, and B is itself a redirect page, then a reader navigating to A will see the display of the redirect page B (as illustrated). See Double redirects. (Bots fix such chains so that each redirect points directly to the final target page.)
A redirect page viewed directly, either in the situations described above, or when the URL used to access the page contains the query parameter redirect=no
, looks like this:
From Wikipedia, the free encyclopedia
Redirect page
(See the actual Transportation redirect page.)
Redirects to articles that begin with a lowercase title, for example the redirect from the page at Ebay.com to the article at eBay, will display the target page with a capitalized first letter, even though the article displays the title with a lowercase title. This is because the true title of the target page is actually capitalized — it just appears lowercase because of the use of the magic word DISPLAYTITLE. (Usually, the template {{Lowercase title}} is used to implement the DISPLAYTITLE magic word for lowercase titles.)
Section redirects
When the redirect target is a section link, following a redirected link should lead to the section or other element identified by the link. Normally the redirected page includes the entire contents of the target page as if the section fragment wasn't specified, and uses JavaScript to jump to the section after the page is loaded. If JavaScript is disabled, this jump does not happen.
When a redirect page is viewed directly without following the target link, the link is shown as an ordinary section link, and works as usual without the use of JavaScript.
Purposes of a redirect
Redirects are usually created because readers may search for an article under different names (or editors may wish to link to it from different names). Examples are:
- Alternative names for the same thing
- Alternative spellings, capitalizations, etc. (although it is not necessary to create redirects from different capitalizations just because readers may enter them in the search box - the Go button in the Monobook skin resolves this automatically)
- Common misspellings
- Plurals
- Subtopics that don't have their own article (in this case, you may redirect to a section of the target page)
- Shortcuts to a page, used mainly in project space (such as WP:AFD)
- Redirects that keep links to a page active after it has been renamed (even if internal links are updated—this still applies for links from outside and links in edit summaries)
Note that it is not necessary to create redirects from every title an editor may conceivably wish to link to a given page – piped links can be used as an alternative.
Creating and editing redirects
- Unregistered users, and those not yet autoconfirmed, can request a redirect be created at Wikipedia:Articles for creation/Redirects. There is also a wizard that less experienced editors can use to create a redirect.
A redirect page can be created like any other page (see Creating a new page). Simply type in the wikitext #REDIRECT [[xxx]]
, replacing "xxx" with the title of the target page (optionally followed by a "#" sign and the section title).
Make sure that there is no text before the #REDIRECT keyword, or the redirect will not work. There is not usually any reason to place any text after the link either, although sometimes categories (or categorizing templates—see Categorizing redirects), interwiki links (see Interlanguage links) or HTML comments (<!-- comment -->
) are added.
Similarly, any existing page can be edited to turn it into a redirect.
To edit a page that is already a redirect (or to view its history, talk page, etc.), follow the redirect to the target page, then click on the link in the "(Redirected from ...)" notice at the top of the page. This takes you to the redirect page itself. (The URL for accessing a redirect page without following the redirect contains the query parameter redirect=no.)
Another way to get to a redirect page is to go to the target page, and click "What links here" (in the toolbox on the left of the page). This will show you all the backlinks to that page, including redirects. Clicking on a redirect in this list will take you to the redirect page, not the target.
The edit summary box can be left blank; the summary will then be automatically generated stating that the page has been redirected to the given target. (This applies for: a new redirect page; an existing article page turned into a redirect page; and a change to the target of an existing redirect.) The generated summary is overridden if the editor supplies their own summary.
Using VisualEditor
To create a redirect using the VisualEditor:
- Open the "page options" menu (icon with three parallel horizontal bars) at the top right of the editor
- Select "Page settings"
- Check the box marked "Redirect this page to"
- Enter the name of the target page in the text box below the checkbox
- Click on the blue "Apply changes" button
- Save the page. You may enter an edit summary, or an automatic summary will be generated.
With Template
For redirecting xyz to article abc, enter xyz here, and type #REDIRECT [[abc]] in the body.
Deleting redirects
Administrators can delete redirects in the same way as any other page. Deletion or other potentially controversial treatment of redirects can be proposed by any editor at Redirects for discussion. Please refer to Wikipedia's deletion policy for details and instructions.
Moving pages
When a page is moved (renamed), a redirect is automatically created from the old to the new name, and also one for the corresponding talk page (if that was moved as well). Administrators and page movers can choose to suppress creation of the redirect.
If the new page name is occupied by a redirect that has only one edit in its history and targeted to the old page name, it is replaced by the page being moved. If the redirect has more than one history entry, or has a different target page, then the move must be made by an administrator or pagemover.
Transclusion
When a page called for transclusion is a redirect page, the redirect target is included instead, with the same parameters, without any redirect message. Hence if Template:AFD is redirected to Template:Afd, then {{AFD|...}}
will have the same effect as {{Afd|...}}
As usual, double redirects are not followed.
Soft redirects
As an alternative to the normal "hard" redirects (which take the reader directly to the target page), it is possible to create "soft" redirects, which leave the reader on the redirect page, giving them the option of clicking the link to the target page. This is usually done in the following situations:
- When the target is on another project (Wiktionary, Meta, other language Wikipedias, etc.) or is a special page. (In these situations a hard redirect would behave as a soft one in any case.)
- For redirects between categories. (Hard redirects work for category pages, but soft ones are preferred because of the software's inability to recategorize pages from redirected categories.)
Soft redirects are created using the templates {{soft redirect}} and {{category redirect}}.
See also
- Category:Redirect templates
- Hatnote and examples for page hatnotes
- Redirect technical help at Meta-Wiki
- Wikipedia:Printability
- Wikipedia:Template messages/Redirect pages
- WikiProject Redirect's style guide
- Wikipedia:Visualizing redirects, for how to make links to redirects stand out (based on the
mw-redirect
CSS class)