[1000programacion] quitar el index.php de un mediawiki

  • From: "Tardo" <tardo@xxxxxx>
  • To: <1000programacion@xxxxxxxxxxxxx>
  • Date: Thu, 12 Oct 2006 23:07:25 +0200

Getting URLs like those on Wikimedia sites

This method will put articles under:


and everything else under:


...just like the WikiMedia sites.

Replace www.mysite.com and /filesystem/path/to/my/site to suit your site.

Using aliases in httpd.conf

This is the prefered method from a performance point of view, but requires
access to edit httpd.conf; unfortunately, such access is unlikely in a
shared hosting environment. It has been tested successfully with MediaWiki

1. In LocalSettings.php, make sure you are using these default values:

$wgScriptPath = "/w";
$wgScript = "$wgScriptPath/index.php";

If you put the wiki installation in a subdirectory such as /w, use
$wgScriptPath = "/w" as appropriate.

If you put the files (such as index.php) in the root, you can use
$wgScriptPath = "" in LocalSettings.php.

2. In LocalSettings.php, set the following:

$wgArticlePath = "/wiki/$1";

Remember, the virtual directory for the wiki article space should never,
ever overlap or hide real files. In particular it should never, ever overlap
your base installation directory or the root directory. It can be a virtual
subdirectory, such as /wiki. (For example: do not try to rewrite
"/wiki/Article" to "/wiki/index.php?title=Article).

3. Set up the following alias in your Apache httpd.conf. It can be in a
<VirtualHost> section or in your general site config. In this alias, the
prefix /filesystem/path/to/my/site represents the path you installed to -
the directory where MediaWiki's index.php lives. Replace the prefix as
appropriate for your actual file system path.

#These must come last, and in this order!
Alias /wiki /filesystem/path/to/my/site/index.php
Alias /index.php /filesystem/path/to/my/site/index.php

After making modifications to httpd.conf, you might have to restart Apache
to apply the changes.

Make sure Apache loads the Rewrite module. In httpd.conf this line must be

LoadModule rewrite_module modules/mod_rewrite.so

After making modifications to httpd.conf, you might have to restart Apache
to apply the changes.

If you are using Apache 2, you might also need to turn on
<http://httpd.apache.org/docs-2.0/mod/core.html> AcceptPathInfo. It is on by
default in a standard installation of Apache and PHP, but some
vendors/packagers may have it disabled on your system.

Using a rewrite rule in a .htaccess file

This method may be useful if you have the ability to use rewrite rules in
.htaccess but don't have conf access. But this method is more work for the

1.      install mediawiki in the dir for www.mysite.com/w as normal (using
the installer)
2.      set $wgArticlePath = "/wiki/$1"; in LocalSettings.php
3.      put a htaccess file with the following content in the dir for

# close the php security hole... 
#  not actually needed but probably a good idea anyway
php_flag register_globals off
# first, enable the processing - Unless your ISP has it enabled
# already.  That might cause weird errors.
RewriteEngine on
# uncomment this rule if you want Apache to redirect from www.mysite.com/ to
#  www.mysite.com/wiki/Main_Page
# RewriteRule ^/$ /wiki/Main_Page [R] 
# do the rewrite
RewriteRule ^wiki/?(.*)$ /w/index.php?title=$1 [L,QSA]


Other related posts:

  • » [1000programacion] quitar el index.php de un mediawiki