A redirect is a page starting with:
#REDIRECT [[pagename]]
where pagename is the target page.
Extra text after the #REDIRECT command and link is ignored. It is rendered only in preview and in a diff.
If the redirect target is an existing page in the same project, going to the redirect page by means of a link, the URL, or the Go button, results in the redirect target page, just like following the link. However, the browser shows the URL of the redirect page, and the target page shows a small notice below the top title to indicate you arrived here indirectly.
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:
Help:Redirect Information
From Wikipedia
(Redirected from Help:Redirection)
To get the canonical URL of the target page in your browser's address bar, click the article tab.
If the redirect target is a non-existing page in the same project, or to a page in another project, one simply arrives at the redirect 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).
As a simple way to avoid problems with infinite 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.
When creating new redirects, bear in mind that creating too many redirects can clutter up the 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 piped link is another way to make a link to a page with a name which does not occur in the first page.
If you're creating a new redirect, start a new page, write #REDIRECT [[pagename]] (or #redirect [[pagename]]) at the top of the page, where pagename is the name of the target page. Here is 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 #REDIRECT [[pagename]].
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 [1], [2], and [3]. 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 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).
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:
Help:Redirection Information
From Wikipedia
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.
This does not apply in the 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 [4] with the preview of its edit page [5].
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 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.
Once you get to the redirect page, click Edit this page. You can then either change the target of the redirect or replace the redirect with a brand new page.
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.
Administrators can delete redirects in the same way as any other page. There may be project-specific guidelines on when this is appropriate.
When a page is renamed/moved with the moving function, a redirect is automatically created from the old to the new name, and also one for the corresponding talk page.
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.
Interwiki redirects and redirects to special pages have been disabled, try e.g. Help:Interwiki redirect demo and Help:Redirect to special page demo.
Use direct interwiki links (or direct links to Special pages) without redirect, or a soft redirect (non-automatic).
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).
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.
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.
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).
To prevent a page that redirects to a category from appearing in the category; precede the word Category with a colon like so : #REDIRECT [[:Category:Glossary]]
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.
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 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:
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.
(for MediaWiki 1.9.0)
(modified code by Uriah Anthony Stephenson-Ward | [email protected] | DIYinfo.org)
/** * @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; }