使用Mediawiki尝试短URL时,可以使用无限重定向(Apache + Nginx-reverse-proxy)

时间:2019-02-20 04:44:11

标签: apache nginx mediawiki

这个问题几个月以来,我只是无法解决。我在Apache上使用Nginx作为反向代理的Mediawiki 1.31.1和PHP 7.1.26

一切正常...

除非更改短URL的配置。遵循Mediawiki简短的URL指南,任何方法都会导致无限重定向错误(尝试了许多方法)。尝试更改PHP版本,但似乎也无济于事。

相关配置:

nginx反向代理

   server {
        listen   80;
        root /var/www/html;
        index index.php index.html index.htm;
        server_name _;
        location / {
        try_files $uri $uri/ /index.php;
        }
        location ~ \.php$ {
        proxy_set_header X-Real-IP  $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host $host;
        proxy_pass http://127.0.0.1:8080;
         }
         location ~ /\.ht {
                deny all;
        }
    }

Apache配置(位于httpd.conf结尾)

RewriteEngine On
RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/index.php [L]

RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
RewriteRule ^/?images/thumb/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ %{DOCUMENT_ROOT}/thumb.php?f=$1&width=$2 [L,QSA,B]

RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
RewriteRule ^/?images/thumb/archive/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ %{DOCUMENT_ROOT}/thumb.php?f=$1&width=$2&archived=1 [L,QSA,B]

Mediawiki Localsettings.php设置

$wgScriptPath = "";
$wgScriptExtension = ".php";
$wgArticlePath = "/wiki/$1";
$wgEnableUploads  = true;
$wgGenerateThumbnailOnParse = false;

0 个答案:

没有答案