对nginx的rewrite文件写入如下内容,如果是宝塔面板,那么如下图所示添加,并保存。
location ~ ^\/.+$ {
if ($request_uri ~ ^/resources) { break; }
if ($request_uri ~ ^/images) { break; }
if ($request_uri ~ ^/index\.php) { break; }
rewrite ^/(.+)$ /index.php?title=$1 last;
}
or
location ~ ^\/.+$ {
if ($request_uri ~ ^/resources) { break; }
if ($request_uri ~ ^/index\.php) { break; }
rewrite ^/(.+)$ /index.php?title=$1 last;
}
然后再在 LocalSettings.php文件里面添加如下代码
# 伪静态
$wgScriptPath = "";
$wgArticlePath = "$wgScriptPath/$1";
$wgUsePathInfo = true;
$wgScriptExtension = ".php";