【问题标题】:How to remove index.php from the URL of MediaWiki?如何从 MediaWiki 的 URL 中删除 index.php?
【发布时间】:2014-09-24 19:23:26
【问题描述】:

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

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

## 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 Not Found。在此服务器上找不到请求的资源!

【问题讨论】:

  • 你服务器上的重写规则是怎样的?
  • 我的服务器中没有重写规则。没有.htaccess 我只更改了LocalSettings.php 来更改URL。
  • 那就是为什么。你需要告诉你的服务器在这些 url 上提供一些东西。 LocalSettings.php 只能更改 wiki 中的链接,不能更改服务器的行为

标签: php mediawiki


【解决方案1】:

LocalSettings.php 的更改仅影响您 wiki 中的链接。您还需要向您的服务器添加适当的重写规则,以便用户可以看到实际的东西。在您的情况下,假设您正在运行 Apache,将类似这样的内容添加到 .htaccess 可能会起作用:

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

您可以在the manual 中找到您的服务器的详细说明。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-05-15
    • 1970-01-01
    • 2013-05-15
    • 2019-08-16
    相关资源
    最近更新 更多