MediaWikiをショートURLにする
提供: すだちWiki
「index.php」が含まれないショートURLにする。
※この方法は MediaWiki に存在する「images」などの、ディレクトリ名を記事名にすることは出来ません。403エラーが帰ってきます。
WAN
|
+----------------------+ +-----------------------+
| http://sudachi.jp | | /wiki/ |
| +------------+ |
| .htaccess | | MediaWiki 本体 |
| index.php | | LocalSettings.php |
| robots.txt | | .htaccess |
+----------------------+ +-----------------------+
LocalSettings.phpの書き換え
[wiki]サブディレクトリにインストールしている場合。
$wgScriptPath = "/wiki"; $wgScript = "$wgScriptPath/index.php"; $wgArticlePath = "$wgScriptPath/$1";
.htaccessの書き換え
[wiki]サブディレクトリの.htaccessに書きくわえる。
RewriteEngine on
RewriteBase /wiki/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?title=$1 [L,QSA]
トップページ対策
ドメイントップのアクセス対策をします。
ここの場合だと、[http://sudachi.jp/]に設置します。
.htaccess
[.htaccess]を設置します。サブディレクトリで他のCMSも動かしているので下記のようになりました。
DirectoryIndex index.php
index.php
<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: /wiki/") ;
?>
