Mediawiki 子目录安装
可能的重复: 子目录和子域上的 MediaWiki (但是没有答案,也没有任何提供帮助的回复)
好吧,我正在尝试将 MediaWiki 配置为安装到子目录。我之前使用 mod_rewrite 将其安装到 http://www.example.com/ 上的主域使用 /wiki/Main_Title
的短 URL。
请注意,我也在 HostGator 共享主机,其中有 短网址的特殊规则。
我的目录结构如下:
/
(站点根目录;.htaccess 的位置)
/wiki/
(mediawiki 根;LocalSettings.php 的位置)
这是我尝试过的,
.htaccess
:
RewriteEngine on
RewriteBase /
RewriteRule ^(.*)\&(.*)$ $1\%26$2
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^wiki/(.+)$ ./wiki/index.php?title=$1 [PT,L,QSA]
/wiki/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 = "/wiki";
$wgScriptExtension = ".php";
$wgArticlePath = "$wgScriptPath/$1";
但是,我什么也没得到。我只是收到 403/Forbidden
错误;没有 500 内部服务器错误
,只是 403 - url http://www.example.com/ example.com/。就好像什么都没做一样。我把头撞在墙上试图解决这个问题。任何帮助表示赞赏。
提前致谢!
Possible Duplicate: MediaWiki on SubDirectory and SubDomain (However doesn't have an answer, nor any replies offering help)
Alright, I'm trying to configure MediaWiki to be installed to a sub-directory. I previously had it installed to a primary domain on http://www.example.com/ with a mod_rewrite using a Short URL of /wiki/Main_Title
.
As a note, I'm also on HostGator shared hosting which has special rules for short urls.
My directory structure is as such:
/
(site root; location of .htaccess)
/wiki/
(mediawiki root; location of LocalSettings.php)
Here's what I tried,
.htaccess
:
RewriteEngine on
RewriteBase /
RewriteRule ^(.*)\&(.*)$ $1\%26$2
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^wiki/(.+)$ ./wiki/index.php?title=$1 [PT,L,QSA]
/wiki/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 = "/wiki";
$wgScriptExtension = ".php";
$wgArticlePath = "$wgScriptPath/$1";
However, I do not get anything. I simply get a 403/Forbidden
error; no 500 Internal Server Error
, just a 403 - url http://www.example.com/. It's as if there's nothing being done. I've banged my head against the wall trying to figure this out. Any help is appreciated.
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
的目的是什么?你在这件事上完全迷失了我。任何带有第二个参数的 URI 将无限循环并生成 500 状态返回。
如果您阅读了 Rewrite 文档:
RewriteCond通常是查询参数的一部分。如果 URI 格式错误(例如
fred&q=1
),它可能会出现在 RewriteRule 模式中。默认情况下,mod_rewrite 会将其视为fred?q=1
,但这会将其转换为转义的 %26 变体,因此它将作为标题fred&q=1
传递> 到 MW(顺便说一句,这是一个无效的 MW 标题)。我认为你应该摆脱它或者至少理解你在这里想做什么。最后一行应该是
并保留
RewriteBase
,否则 mod_rewrite 可能会感到困惑。这应该可以正常工作:-)
What is the purpose of
You've lost me entirely on this one. Any URI with a second parameter will loop indefinitely and generate a 500 status return.If you read the Rewrite documentation:
The & is normally part of the query parameter. It can appear in the RewriteRule pattern in the case of malformed URI (e.g.
fred&q=1
). By default, mod_rewrite will treat this asfred?q=1
, but this converts it to the escaped %26 variant so this would be passed as a titlefred&q=1
to MW (which is an invalid MW title by the way). I think that you should get rid of it or at least understand what you are trying to do here.The last line should be
and keep the
RewriteBase
otherwise mod_rewrite can get confused.This should work OK:-)
您走在正确的道路上...如果您在共享环境中,请尝试以下操作:
两个提示:
如果您不在托管环境中(=如果它是您自己的服务器并且您可以修改虚拟主机,不仅仅是
.htaccess
文件),尝试使用RewriteLog
指令:它可以帮助您追踪此类问题:我最喜欢的检查正则表达式的工具:
http://www.quanetic.com/Regex (不要忘记选择 ereg(POSIX) 而不是 preg (PCRE)!)
You're on the right track... if you're on a shared environment, then try this:
Two hints:
If you're not in a hosted environment (= if it's your own server and you can modify the virtual hosts, not only the
.htaccess
files), try to use theRewriteLog
directive: it helps you to track down such problems:My favorite tool to check for regexp:
http://www.quanetic.com/Regex (don't forget to choose ereg(POSIX) instead of preg(PCRE)!)
我的 HostGator 票解决了这个问题,尽管没有什么帮助。我希望有一个单一
.htaccess
解决方案,而不是双重.htaccess
重定向/重写。但是,这是我的解决方案。/
:/wiki/
:My ticket to HostGator resolved the issue, albeit un-helpfully. I was hoping for a single
.htaccess
solution, rather than a double.htaccess
redirect/rewrite. However, here's my solution./
:/wiki/
:我尝试了不同的解决方案,对我有用的是将 mediawiki 子文件夹中的 .htaccess 更改为
I tried different solutions and what worked for me was changing .htaccess in mediawiki subfolder to