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