提供:EELの自由帳
移動先: 案内検索

MediaWikiに通常のページの閲覧以外の動作に'pretty'URLのパスを設定

はじめに

様々なユーザアクションのためのパス。'pretty'URLに使用されます。通常のページの閲覧以外の動作に'pretty'URLのパスを設定するには、この配列に加えてください。

設定

LocalSettings.phpに以下の追加をしてください。

## https://www.mediawiki.org/wiki/Manual:Short_URL
$wgScriptPath = "/wiki125";

## ショートURLにする
$wgScript           = "$wgScriptPath/index.php";
$wgArticlePath      = "$wgScriptPath/$1";

$wgScriptExtension = ".php";

## 追加はじめ
## 通常のページの閲覧以外の動作に'pretty'URLのパスを設定
$actions = array('view', 'edit', 'watch', 'unwatch', 'delete','revert', 'rollback', 'protect',
  'unprotect','info','markpatrolled','validate','render','deletetrackback','print',
  'dublincore','creativecommons','credits','submit','viewsource','history','raw',
  'purge');
foreach ($actions as $a) 
  $wgActionPaths[$a] = "$wgScriptPath/action/$a/$1";
$wgArticlePath = "$wgScriptPath/action/view/$1";
## 追加おわり
## The protocol and server name to use in fully-qualified URLs
$wgServer = "//sudachi.jp";

.htaccessに以下の追加をしてください。

RewriteEngine On
RewriteBase /wiki125/

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?title=$1 [L,QSA]

RewriteRule ^/action/([a-z]*)/(.*)$ /index.php?action=$1&title=$2 [L,QSA] ← 追加

動作

http://sudachi.jp/wiki125/特別:特別ページ一覧

http://sudachi.jp/wiki125/action/view/特別:特別ページ一覧
http://sudachi.jp/wiki125/メインページ

http://sudachi.jp/wiki125/action/view/メインページ