Mediawiki后伪静态设置

Nginx安装Mediawiki后,假设安装在网站根目录。

对nginx的rewrite文件写入如下内容

location ~ ^\/.+$ {
if ($request_uri ~ ^/images) { break; }
if ($request_uri ~ ^/resources) { break; }
if ($request_uri ~ ^/index\.php) { break; }
rewrite ^/(.+)$ /index.php?title=$1 last;
}

随后在LocalSettings.php中寻找

$wgScriptPath = "";

找到后在下面添加以下内容:

$wgArticlePath = "$wgScriptPath/$1";

重载Nginx即可完成伪静态配置。

--------------20210713--------------------------------------------

nginx 重写去掉index.php

location /rest.php/ {
try_files $uri $uri/ /rest.php? $query_string ;
}


location / {
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php?title=$1 last;
break;
}
}

 

-------------------

LocalSettings.php

$wgScriptPath = "";
$wgArticlePath = "/$1"; # 虚拟路径,必须与 $wgScriptPath 不同
$wgUsePathInfo = true; # 启用 pretty URLs

posted @ 2021-04-22 14:34  奋斗小青年1  阅读(325)  评论(0)    收藏  举报