如何从MediaWiki的URL中删除index.php


How to remove index.php from the URL of MediaWiki?

我使用了这个工具http://shorturls.redwerks.org/为MediaWiki重写一个简短的url。从此:http://wikitest.org/fr/index.php/Accueil到此:http://wikitest.org/fr/wiki/Accueil

然后我将此代码添加到LocalSettings.pp:

## The URL base path to the directory containing the wiki;
## defaults for all runtime URL paths are based off of this.
## For more information on customizing the URLs please see:
## http://www.mediawiki.org/wiki/Manual:Short_URL
$wgScriptPath = "/fr";
$wgScriptExtension = ".php";
$wgArticlePath = "{$wgScriptPath}/wiki/$1";
$wgUsePathInfo = true

但当我访问我的网站时,我会得到404未找到。在此服务器上找不到请求的资源

LocalSettings.php的更改仅影响wiki中的链接。您还需要将适当的重写规则添加到服务器中,这样用户就可以真正看到一些内容。在您的情况下,假设您运行的是Apache:,那么在.htaccess中添加这样的内容可能会起作用

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

您可以在手册中找到有关服务器的详细说明。