【问题标题】:Use short URL to refer to MediaWiki site with Apache virtual host使用短 URL 引用带有 Apache 虚拟主机的 MediaWiki 站点
【发布时间】:2021-12-30 11:31:59
【问题描述】:

我在 Apache 上的设置:

  • /var/www/sandbox.example.org/wiki
  • 我有一个从http://sandbox.example.org 到 https://sandbox.example.org 的永久重写;有一个http配置文件和一个https配置文件
  • 在 Apache 配置文件中:DocumentRoot /var/www/sandbox.example.org/wiki
  • 在 Apache 配置文件中:DirectoryIndex index.php

我将 Mediawiki 放在 /var/www/sandbox.example.org/wiki 文件夹中,然后进行了安装。

LocalSettings.php 自动获取:$wgScriptPath = "";

作为浏览器中的 URL,我得到:https://sandbox.example.org/index.php?title=MainPage

我想要的:https://sandbox.example.org/wiki/MainPage

我按照/尝试了https://www.mediawiki.org/wiki/Manual:Short_URL/Apache 上的说明,但没有任何效果。

如何做到这一点?

【问题讨论】:

    标签: apache mediawiki short-url


    【解决方案1】:

    找到了解决办法!有兴趣的朋友:

    在虚拟主机配置文件中, 标签内有:

    DocumentRoot /var/www/sandbox.example.org
    DirectoryIndex w/index.php
    
    RewriteEngine On
    RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/w/index.php [L]
    

    在 MediaWiki 安装的 LocalSettings.php 中:

    $wgArticlePath = "/wiki/$1";
    $wgUsePathInfo = true;
    

    所以现在我有:http://sandbox.example.org/wiki/MainPage 而不是 http://sandbox.example.org/w/index.php?title=MainPage

    【讨论】:

      猜你喜欢
      • 2014-01-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-25
      • 2020-11-18
      • 2018-07-04
      • 2015-01-31
      相关资源
      最近更新 更多