Handbuch:$wgActionPaths

This page is a translated version of the page Manual:$wgActionPaths and the translation is 45% complete.
Server-URLs und Dateipfade: $wgActionPaths
Paths for various user actions. Used to make URLs prettier.
Eingeführt in Version:1.5.0 (r7538)
Entfernt in Version:weiterhin vorhanden
Erlaubte Werte:nicht angegeben
Standardwert:[]

Details

Setup Handbuch:Kurz-URL and ensure it is working first

Um "pretty" URL-Pfade für andere Aktionen als plain-Seitenansichten einzustellen, fügen Sie das diesem Array hinzu.

Zum Beispiel:

$wgActionPaths['edit'] = "$wgScriptPath/edit/$1";

Es muss eine entsprechendes Skript oder eine Umschreibungsregel vorhanden sein, um diese URLs zu verarbeiten.

Beispielkonfigurationen

These examples include sample .htaccess files for Apache servers using mod_rewrite.

Other servers will have other ways of accomplishing URL rewrites.

Action paths from root

This sets up action paths of the form http://mywiki.example.com/edit/Cucumber etc.

LocalSettings.php
$actions = [
	'view',
	'edit',
	'watch',
	'unwatch',
	'delete',
	'revert',
	'rollback',
	'protect',
	'unprotect',
	'markpatrolled',
	'render',
	'submit',
	'history',
	'purge',
	'info',
];

foreach ( $actions as $action ) {
  $wgActionPaths[$action] = "/$action/$1";
}
$wgArticlePath = $wgActionPaths['view'];

extra htaccess rules

.htaccess
Achten Sie darauf "/mediawiki/index.php" zu ändern, wo Sie MediaWiki installiert haben
RewriteRule ^/([a-z]*)/(.*)$ %{DOCUMENT_ROOT}/w/index.php [L,QSA]

action at the end

This sets up action paths of the form http://mywiki.example.com/Cucumber/edit etc.

$actions = [
	'edit',
	'watch',
	'unwatch',
	'delete',
	'revert',
	'rollback',
	'protect',
	'unprotect',
	'markpatrolled',
	'render',
	'submit',
	'history',
	'purge',
	'info',
];

foreach ( $actions as $action ) {
  $wgActionPaths[$action] = "/$1/$action";
}
$wgActionPaths['view'] = "/$1";
$wgArticlePath = $wgActionPaths['view'];

Non root action paths

For standard example.com/wiki/Main_Page rewrites to example.com/wiki/view/Main_Page use above config and change this line to include "/wiki":

foreach ( $actions as $action ) {
  $wgActionPaths[$action] = "/wiki/$action/$1";
}

For standard example.com/wiki/Main_Page view urls, and rewrites to example.com/wiki/edit/Main_Page

$actions = [
	'edit',
	'watch',
	'unwatch',
	'delete',
	'revert',
	'rollback',
	'protect',
	'unprotect',
	'markpatrolled',
	'render',
	'submit',
	'history',
	'purge',
	'info',
];

foreach ( $actions as $action ) {
  $wgActionPaths[$action] = "/wiki/$action/$1";
}
$wgActionPaths['view'] = "/wiki/$1";
$wgArticlePath = $wgActionPaths['view'];

action at the end

For standard example.com/wiki/Main_Page view urls, and rewrites to example.com/wiki/Main_Page/edit

you cannot have subpages of main pages named "delete, edit, watch, unwatch" etc from the array when setup like this.
$actions = [
	'view',
	'edit',
	'watch',
	'unwatch',
	'delete',
	'revert',
	'rollback',
	'protect',
	'unprotect',
	'markpatrolled',
	'render',
	'submit',
	'history',
	'purge',
	'info',
];

foreach ( $actions as $action ) {
  $wgActionPaths[$action] = "/wiki/$1/$action";
}
$wgActionPaths['view'] = "/wiki/$1";
$wgArticlePath = $wgActionPaths['view'];

Virtual action / directories

This sets up URLs such as http://mywiki.example.com/wiki/action/edit/Cucumber etc.

Um die meisten[1] Aktionen für einen bestimmten Pfad neu zu schreiben, könnte man die folgenden Änderungen an der LocalSettings.php machen:

$actions = [
	'view',
	'edit',
	'watch',
	'unwatch',
	'delete',
	'revert',
	'rollback',
	'protect',
	'unprotect',
	'markpatrolled',
	'render',
	'submit',
	'history',
	'purge',
	'info',
];

foreach ( $actions as $action ) {
  $wgActionPaths[$action] = "$wgScriptPath/action/$action/$1";
}
$wgArticlePath = $wgActionPaths['view'];

In Apache, programmiere eine Umschreibungsregel ähnlich wie die folgende:

RewriteRule ^/action/([a-z]*)/(.*)$ /index.php [L,QSA]

This will forward all requests to /action/actionword/title to MediaWiki's index.php which will parse the action and title according to your $wgActionPaths settings.

Bei der Konfiguration von Apache mod_negotation, um PHP Skripte auszuführen, sollte darauf geachtet werden, um nicht (406 Nicht akzeptable?) Fehler zu verursachen, wenn mit dieser Methode gearbeitet wird, die möglicherweise in einigen Fällen eine Verzeichnisliste aussetzen, siehe [1], [2]. Siehe auch bugzilla:21617.

Spam Vorbeugung

Die Verwendung von $wgActionPaths, insbesondere für die Bearbeiten-Aktion scheint die Zahl der von Spam-Bots versuchten Artikelbearbeitungen zu reduzieren. Es wird vermutet, dass Bots programmiert sind um nach action=edit zu suchen, um eine MediaWiki-Installation zu erkennen und entsprechend zu handeln. In diesem Sinne, wäre es von Vorteil Ihr action-Präfix in etwas nicht offensichtlichen zu benennen, so können Bots Ihre Webseite nicht finden, wenn sie auf der Suche nach action/edit sind.


  1. It is currently not possible to have a $wgActionPath for the 'raw' action.