简体   繁体   English

使用短 URL 以 Apache 虚拟主机引用 MediaWiki 站点

[英]Use short URL to refer to MediaWiki site with Apache virtual host

My setup on Apache:我在 Apache 上的设置:

  • /var/www/sandbox.example.org/wiki /var/www/sandbox.example.org/wiki
  • I have a permanent rewrite from http://sandbox.example.org to https://sandbox.example.org;我有一个从http://sandbox.example.org到 https://sandbox.example.org 的永久重写; there is an http config file and an https config file有一个 http 配置文件和一个 https 配置文件
  • In Apache config files: DocumentRoot /var/www/sandbox.example.org/wiki在 Apache 配置文件中: DocumentRoot /var/www/sandbox.example.org/wiki
  • In Apache config files: DirectoryIndex index.php在 Apache 配置文件中: DirectoryIndex index.php

I put Mediawiki in the /var/www/sandbox.example.org/wiki folder and then did the installation.我将 Mediawiki 放在 /var/www/sandbox.example.org/wiki 文件夹中,然后进行安装。

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

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

What I want: https://sandbox.example.org/wiki/MainPage我想要什么: https://sandbox.example.org/wiki/MainPage

I followed / tried instructions on https://www.mediawiki.org/wiki/Manual:Short_URL/Apache , but with no effect.我按照/尝试了https://www.mediawiki.org/wiki/Manual:Short_URL/Apache上的说明,但没有效果。

How to do this?这个怎么做?

Found the solution: For the ones who are interested:找到了解决方案:对于那些感兴趣的人:

In the virtual host configuration file, there is among others within the <VirtualHost *:80> tag:在虚拟主机配置文件中,<VirtualHost *:80> 标记内还有其他内容:

DocumentRoot /var/www/sandbox.example.org
DirectoryIndex w/index.php

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

And in the LocalSettings.php of the MediaWiki installation:在 MediaWiki 安装的 LocalSettings.php 中:

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM