2014-09-24 165 views
1

我用这个工具http://shorturls.redwerks.org/为MediaWiki重写了一个简短的URL。 从此出发:http://wikitest.org/fr/index.php/Accueil至此:http://wikitest.org/fr/wiki/Accueil如何从MediaWiki的URL中删除index.php?

Then I added this code to 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未找到。在此服务器上找不到请求的资源!

+0

你的服务器上的重写规则是怎么样的? – leo 2014-09-25 12:14:29

+0

我的服务器中没有重写规则。没有.htaccess我只改变了LocalSettings.php来改变URL。 – 2014-09-26 15:26:57

+1

那就是为什么。你需要告诉服务器在这些URL上提供服务。 LocalSettings.php只能更改wiki中的链接,而不能更改服务器的行为 – leo 2014-09-26 18:35:52

回答

4

LocalSettings.php的更改仅影响wiki中的链接。您还需要将适当的重写规则添加到您的服务器,以便实际上有一些内容供用户查看。在你的情况下,加入这样的事情.htaccess可能会奏效,假设你正在运行的Apache:

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

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

1

在这篇文章中已经有一段时间了,但如果它对别人有帮助。按照我在mediawiki中找到的说明,我可以在我的网站中完成此操作。这是一个MediaWiki Short URL builder http://shorturls.redwerks.org/ 你添加了你想要的路径,它会引发你添加到你的LocalSettings.php以及web.config的指令 它对我很有效,我希望它适合你。