[1000programacion] mediawiki - quitar el index.php

  • From: "Tardo" <tardo@xxxxxx>
  • To: <1000programacion@xxxxxxxxxxxxx>
  • Date: Fri, 13 Oct 2006 13:13:49 +0200

Getting URLs like those on Wikimedia sites


This method will put articles under:

www.mysite.com/wiki/articlename 

and everything else under:

www.mysite.com/w/index.php?whatever 

...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.4.4.

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
added/uncommented:

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 AcceptPathInfo
<http://httpd.apache.org/docs-2.0/mod/core.html> . 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
httpd.

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
www.mysite.com

# 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]

Moving mediawiki to another directory


If you didn't follow the instructions and installed MediaWiki in the
directory for www.mysite.com/wiki, then you will need to move it to another
directory, such as "w". You will need to change the various paths (such as
$IP) in LocalSettings.php to the new location.


Purging cache


If you notice that your changes to $wgArticlePath in LocalSettings.php are
not being reflected in mysite.com/wiki/Main_Page, it may be due MediaWiki's
caching of the links according to previous settings.

Go to mysite.com/wiki/Main_Page?action=purge to force MediaWiki to
regenerate the cached links.

Also you can:

1.      execute the MySQL query "DELETE FROM objectcache;", or
2.      set $wgCacheEpoch to the current date.


Troubleshooting


If you get internal server errors or similar, check out the Apache
error.log. This usually has some clues about the reasons.

 

 

De aquí:
http://meta.wikimedia.org/wiki/Eliminating_index.php_from_the_url#Using_alia
ses_in_httpd.conf

Other related posts:

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