宝塔面板 + Nginx
1、vhost上配置重定向,准确路径为/www/server/panel/vhost/nginx找到对应的网站文件,如www.iec.wiki.conf
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
try_files $uri /index.php;
expires max;
log_not_found off;
}
location = /_.gif {
expires max;
empty_gif;
}
location ^~ /cache/ {
deny all;
}
location /dumps {
root /var/www/mediawiki/local;
autoindex on;
}
location ~ /\.ht {
deny all;
}
location / {
try_files $uri $uri/ @rewrite;
}
location @rewrite {
rewrite ^/([^?]*)(?:\?(.*))? /index.php?title=$1&$2 last;
}
#一键申请SSL证书验证目录相关设置
location ~ \.well-known{
allow all;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
try_files $uri /index.php;
expires max;
log_not_found off;
}
location = /_.gif {
expires max;
empty_gif;
}
location ^~ /cache/ {
deny all;
}
location /dumps {
root /var/www/mediawiki/local;
autoindex on;
}
location ~ /\.ht {
deny all;
}
location / {
try_files $uri $uri/ @rewrite;
}
location @rewrite {
rewrite ^/([^?]*)(?:\?(.*))? /index.php?title=$1&$2 last;
}
—————————————————————————————————-
2,
代码
if ($server_port !~ 443){
rewrite ^(/.*)$ https://$host$1 permanent;
}
修改为
#301-START
if ($host ~ '^emc.wiki'){
r eturn 301 https://www.emc.wiki$request_uri;
}
#301-END
3、配置文件localsettings.php添加如下代码
# 静态化
$wgScriptPath = "";
$wgArticlePath = "/wiki/$1";
$wgVariantArticlePath = "/$2/$1";
$wgUsePathInfo = true;