Help:Redirect

A redirect is a page that automatically redirects the reader's browser to a specified target page. Redirects are used to help users locate information and keep wikis organized, so that multiple names, abbreviations, misspellings, or related topics can all point to the same page.

A redirect is created by the text

#REDIRECT [[name of the target page]]

As an example, if the page 'Foo' starts with the line #REDIRECT [[Bar]], then a person who visits the page 'Foo' will be shown the page 'Bar' with a note that they were redirected from 'Foo'. The page 'Bar' does not need anything in it to be the target of the redirection.

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:

On visiting any page on a simple chain of redirects, the browser is redirected to the final destination. If the chain forms a loop, the browser is brought to its predecessor and the redirect loop is displayed. See, e.g. Redirect 1-> Redirect 2 ->Redirect 3 -> Redirect 1.

A redirect target cannot depend on a variable, template, or parser function. If that is the case, the browser will not be automatically redirected on visiting the page. See, e.g. /expr

A code like %70 in a redirect disables it, although the link works from the redirect page.

Some projects have policies on what redirects should exist. For example, on the English Wiktionary, most redirects are prohibited by policy.

Conveniently linking indirectly to a page, without the need for a Piped link. However, a piped link is in some respects even better than relying on a redirect, see 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 [[30.48 cm|ft]], 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 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 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, as displayed at 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:

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.

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, replace the redirect with a brand new page or revert to an earlier version of the article, before it became a redirect.

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.

A broken redirect is a redirect whose target page does not exist. This type of redirect does not function and redirection will not occur. Broken redirects are logged at Special:BrokenRedirects.

On many wikis administrators simply delete them, but it is sometimes useful to keep a broken redirect and wait for the creation of the target, or to set a new target. For an example, see Help:Redirect/Broken redirect.

When a page is moved, a redirect from the old to the new pagename is automatically created.

If the new pagename 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 can only be deleted-and-moved by an administrator.

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:

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 ("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 soft redirect from B to A, i.e. a page only containing something like "See [[A]]"; one can see at A that B is very short using the 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)

[edit]Force all redirects to be client side redirects (HTTP 302 Temporary Redirect)

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:

/**
* @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 redirectreturnfalse;}

It works for all Version since 1.14.0. The Hook InitializeArticleMaybeRedirect was actually introduced in 1.13.0, but the $article parameter used was missing back then. If you're using a version prior to 1.14.0, you could insert the function body directly at the position in includes/Wiki.php, where the hook was placed later, but you really need to know what you're doing then.