Apache Mediawiki子目录安装

Apache Mediawiki子目录安装,apache,mod-rewrite,mediawiki,subdirectory,Apache,Mod Rewrite,Mediawiki,Subdirectory,可能重复:(但是没有答案,也没有任何提供帮助的回复) 好的,我正在尝试将MediaWiki配置为安装到子目录。我以前将它安装到上的主域,并使用/wiki/Main\u Title的短URL进行修改 作为一个说明,我也在共享主机上有短网址 我的目录结构如下: /(站点根目录;.htaccess的位置) /wiki/(mediawiki根目录;LocalSettings.php的位置) 这是我试过的 .htaccess: RewriteEngine on RewriteBase / Rewrit

可能重复:(但是没有答案,也没有任何提供帮助的回复)

好的,我正在尝试将MediaWiki配置为安装到子目录。我以前将它安装到上的主域,并使用
/wiki/Main\u Title
的短URL进行修改

作为一个说明,我也在共享主机上有短网址

我的目录结构如下:

  • /
    (站点根目录;.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]
## 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";
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^.*$ http://www.example.com/wiki/
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?title=$1 [L,QSA]
/wiki/LocalSettings.php

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]
## 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";
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^.*$ http://www.example.com/wiki/
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?title=$1 [L,QSA]
然而,我什么也没有得到。我只是得到一个
403/禁止的
错误;没有
500内部服务器错误
,只有403-url。好像什么都没做。为了弄清楚这件事,我把头撞在墙上。感谢您的帮助


提前谢谢

你在正确的轨道上。。。如果您在共享环境中,请尝试以下操作:

RewriteEngine on
# Comment to force base to be the subdir:
# RewriteBase /
RewriteRule ^(.*)\&(.*)$ $1\%26$2
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^wiki/(.+)$ ./wiki/index.php?title=$1 [PT,L,QSA]

两个提示: 如果您不在托管环境中(=如果它是您自己的服务器,您可以修改虚拟主机,而不仅仅是
.htaccess
文件),请尝试使用
RewriteLog
指令:它可以帮助您跟踪此类问题:

# Trace:
# (!) file gets big quickly, remove in prod environments:
RewriteLog "/web/logs/mywebsite.rewrite.log"
RewriteLogLevel 9
RewriteEngine On

我最喜欢的检查regexp的工具:


(别忘了选择ereg(POSIX)而不是preg(PCRE)!

这是为了什么

RewriteRule ^(.*)\&(.*)$ $1\%26$2
在这件事上你完全失去了我。任何带有第二个参数的URI都将无限循环并生成500状态返回

如果您阅读了重写文档:

什么是匹配的?

…如果你想和。。。查询字符串时,请使用带有<代码>%{QUERY\u STRING}
变量

&通常是查询参数的一部分。在URI格式错误的情况下(例如,
fred&q=1
),它可能出现在重写规则模式中。默认情况下,mod_rewrite会将其视为
fred?q=1
,但这会将其转换为转义的%26变量,以便将其作为标题
fred&q=1
传递给MW(顺便说一下,这是一个无效的MW标题)。我认为你应该摆脱它,或者至少理解你在这里想做什么

最后一行应该是

RewriteRule ^wiki/(.+) wiki/index.php?title=$1 [PT,L,QSA]
并保留
RewriteBase
,否则mod_rewrite可能会混淆


这应该可以:-)

我的HostGator机票解决了这个问题,尽管没有帮助。我希望有一个单一的
.htaccess
解决方案,而不是双重
.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]
## 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";
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^.*$ http://www.example.com/wiki/
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?title=$1 [L,QSA]

/wiki/

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]
## 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";
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^.*$ http://www.example.com/wiki/
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?title=$1 [L,QSA]

我尝试了不同的解决方案,对我有效的方法正在改变。mediawiki子文件夹中的htaccess

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wikifolder/index.php [L]
</IfModule>

重新启动发动机
重写基/
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/wikifolder/index.php[L]

此外,如果需要更多信息,请询问,我将尽力提供您需要的任何信息。:)我在一个共享主机环境中,具有cPanel和FTP访问权限,可能存在重复。我在哪里可以访问这些日志?O.oI尝试了
.htaccess
解决方案来启用重写日志,但我得到了一个500 ISE::如果您在共享主机上,那么您无法启用日志,否则您将得到一个500 ISE。你能试着在你自己的电脑上本地安装它吗?试着制作一个vhost并应用你所需要的一切,直到它工作为止?否则可能很难找到错误的确切位置…更新了我的答案。希望这有帮助!似乎不起作用:(我想到的一个解决方案是使用两次重写(每个目录中一次),其中根(
/
)重写为
/wiki/
,而
/wiki/
中的那一行重写了mediawiki。我希望这是有意义的?这一行的目的是来自mediawiki的wiki,用于HostGator上的ShortURL配置。@Zack,这可能是Choshi在2009年编辑的,但它无效。请参阅MW talk页面。这没有意义,因为&是QU的一部分ERY_字符串,引擎将其从模式中剥离。在重写规则中,您将永远不会匹配\。我已更新我的帖子。