Manual:$wgActionPaths

From mediawiki.org
This page is a translated version of the page Manual:$wgActionPaths and the translation is 55% complete.
サーバー URL とファイル パス: $wgActionPaths
利用者の様々な操作に対応するパス。URLをより綺麗に見やすくするために使用します。
導入されたバージョン:1.5.0 (r7538)
除去されたバージョン:使用中
許容される値:未指定
既定値:[]

詳細

まずManual:短縮URL をセットアップし、動作することを確認します。

通常のページの閲覧以外の動作に'pretty'URLのパスを設定するには、この配列に加えてください。

用例としては:

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

これらのURLを扱うためには、適切なスクリプトか"rewrite rule"を設置する必要があります。

設定例

これらの例には、mod_rewrite を使用する Apache サーバー用の .htaccess ファイルのサンプルが含まれています。

Other servers will have other ways of accomplishing URL rewrites.

ルートからの動作パス

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
Be sure to modify "/w/index.php" to where you have MediaWiki installed
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

このオプションは"rewrite rule"が機能するために適切なオプションが必要です。

To rewrite most[1] actions to a specific path, one could make the following changes to LocalSettings.php :

$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'];

Apache では、rewrite rule のコードは下記のようになります。:

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

これは /action/actionword/title の全てのリクエストを index.php?action=actionword&title=title に転送するでしょう。

When configuring Apache mod_negotation to execute PHP scripts when using this method care should be taken not to cause 406 Not Acceptable errors that might in some cases expose a directory listing, see [1], [2]. bugzilla:21617 も参照してください。

スパムの予防手段

$wgActionPathsを使用する事で、特にedit 動作で記事編集を試みるスパムの検索ロボット(bots)の数を減少させるように思えます。 検索ロボット(bots)がMediaWikiインストレーションとその内容を特定するためにaction=editを探すようにプログラムされている疑いがあります。 この点を考慮して、検索ロボット(bots)がaction/editを探し始めたときに、あなたのサイトを見つけることができないように、action 接頭辞を何か明白でない名称にするのは有益でしょう。


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