问题
I used this tool http://shorturls.redwerks.org/ to rewrite a short url for MediaWiki.
From this: http://wikitest.org/fr/index.php/Accueil
to this: http://wikitest.org/fr/wiki/Accueil
.
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
But when I go to my site I get 404 Not Found. The resource requested could not be found on this server!
回答1:
The changes to LocalSettings.php
affects only the links in your wiki. You also need to add the proper rewrite rules to your server,so that there is actually something there for the user to see. In your case, adding something like this to .htaccess
might work, assuming you are running Apache:
RewriteEngine On
RewriteRule ^/?fr/wiki(/.*)?$ %{DOCUMENT_ROOT}/w/index.php [L]
RewriteRule ^/fr*$ %{DOCUMENT_ROOT}/w/index.php [L]
You can find detailed instructions for your server in the manual.
回答2:
It has been a while in this post, but in case it it helpful for someone else. I was able to do it in my site following these instructions I found in mediawiki. It is a MediaWiki Short URL builder http://shorturls.redwerks.org/ you add the path you want and it throws you the instructions to add to your LocalSettings.php and also to web.config It worked for me I hope it works for you.
来源:https://stackoverflow.com/questions/26024848/how-to-remove-index-php-from-the-url-of-mediawiki