Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/285.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 将Mediawiki的短URL与Nginx一起使用_Php_Nginx_Mediawiki - Fatal编程技术网

Php 将Mediawiki的短URL与Nginx一起使用

Php 将Mediawiki的短URL与Nginx一起使用,php,nginx,mediawiki,Php,Nginx,Mediawiki,老实说,我对使用Nginx还不熟悉,但它似乎足够简单。 我刚刚在我的服务器上安装了一个Mediawiki,应用了数据库,等等,它在 不过,我想使用短URL。我已经使用redwerks工具构建了我的nginx配置,并将更改应用于LocalSettings.php。nginx.conf设置起作用-站点正在使用这些设置运行。然而,当我将这些设置添加到LocalSettings.php时,我得到了404 我添加的404的本地设置是: $wgArticlePath = "/$1"; $wgUs

老实说,我对使用Nginx还不熟悉,但它似乎足够简单。 我刚刚在我的服务器上安装了一个Mediawiki,应用了数据库,等等,它在

不过,我想使用短URL。我已经使用redwerks工具构建了我的nginx配置,并将更改应用于LocalSettings.php。nginx.conf设置起作用-站点正在使用这些设置运行。然而,当我将这些设置添加到LocalSettings.php时,我得到了404

我添加的404的本地设置是:

$wgArticlePath      = "/$1";
$wgUsePathInfo      = true;
$wgScriptExtension  = ".php";
$wgGenerateThumbnailOnParse = false;
我的nginx.conf如下:

server {
   listen 80;
   server_name wiki.rebirthgaming.org;

   root /var/www/wiki.rebirthgaming.org;
   index index.php;

    location / {
        try_files $uri $uri/ wiki.rebirthgaming.org;

        # Do this inside of a location so it can be negated
        location ~ \.php$ {
            try_files $uri $uri/ =404; # Don't let php execute non-existent php files
            include /etc/nginx/fastcgi_params;
            fastcgi_pass 127.0.0.1:9000;
        }
    }

    location /images {
        # Separate location for images/ so .php execution won't apply

        location ~ ^/images/thumb/(archive/)?[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ {
            # Thumbnail handler for MediaWiki
            # This location only matches on a thumbnail's url
            # If the file does not exist we use @thumb to run the thumb.php script
            try_files $uri $uri/ @thumb;
        }
    }
    location /images/deleted {
        # Deny access to deleted images folder
        deny    all;
    }

    # Deny access to folders MediaWiki has a .htaccess deny in
    location /cache       { deny all; }
    location /languages   { deny all; }
    location /maintenance { deny all; }
    location /serialized  { deny all; }

    # Just in case, hide .svn and .git too
    location ~ /.(svn|git)(/|$) { deny all; }

    # Hide any .htaccess files
    location ~ /.ht { deny all; }

    # Uncomment the following code if you wish to hide the installer/updater
    ## Deny access to the installer
    #location /mw-config { deny all; }

    # Handling for the article path
    location wiki.rebirthgaming.org {
        include /etc/nginx/fastcgi_params;
        # article path should always be passed to index.php
        fastcgi_param SCRIPT_FILENAME   $document_root/index.php;
        fastcgi_pass  127.0.0.1:9000;
    }

    # Thumbnail 404 handler, only called by try_files when a thumbnail does not exist
    location @thumb {
        # Do a rewrite here so that thumb.php gets the correct arguments
        rewrite ^/images/thumb/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ /thumb.php?f=$1&width=$2;
        rewrite ^/images/thumb/archive/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ /thumb.php?f=$1&width=$2&archived=1;

        # Run the thumb.php script
        include /etc/nginx/fastcgi_params;
        fastcgi_param SCRIPT_FILENAME   $document_root/thumb.php;
        fastcgi_pass  127.0.0.1:9000;
    }
 }  


}
我希望我的URL如下所示: wiki.rebirthgaming.org/Main_页面


我一整天都在试图解决这个问题,尝试不同的设置等,但在更改localsettings时总是失败。

我认为您实际上需要在位置块中设置一个重写规则。作为参考,以下是我所拥有内容的简略版本:

server {

   location / {
        try_files $uri $uri/ @mediawiki;
   }


   location @mediawiki {
         rewrite ^/([^?]*)(?:\?(.*))? /index.php?title=$1&$2 last;
   }
}

我认为你实际上需要在你的位置块里有一个重写规则。作为参考,以下是我所拥有内容的简略版本:

server {

   location / {
        try_files $uri $uri/ @mediawiki;
   }


   location @mediawiki {
         rewrite ^/([^?]*)(?:\?(.*))? /index.php?title=$1&$2 last;
   }
}