[Mediawiki-l] rewrite and htaccess

Saurav Pathak saurav at sas.upenn.edu
Thu Sep 2 22:14:15 UTC 2004


hi,

i have nearly got it to work, except search is not working.  i have
tried different combinations of rewritrules, but to no avail.  what i
use is given below, based on the entry in meta.wikipedia.  obviously
i don't know mod_rewrite well enough to go much beyond.

i am using mediawiki 1.3.1 installed in /wiki/.  the .htaccess file
is in /wiki/. 

The LocalSettings.php variables are:
$wgScriptPath       = "/wiki";
$wgScript           = "$wgScriptPath/index.php";
$wgRedirectScript   = "$wgScriptPath/redirect.php";
$wgArticlePath      = "$wgScriptPath/$1";

Thanks in advance for your help.
saurav
-----
# .htaccess file.
# first, enable the processing
RewriteEngine on
RewriteBase /wiki

# Verifying if user forgot to put trailling slash. If so, we'll rewrite to Main_Page
RewriteCond %{REQUEST_URI}               ^/wiki$
RewriteRule ^(.*)                        /wiki/index.php [L]


# Don't rewrite requests for files in MediaWiki subdirectories,
# MediaWiki PHP files, HTTP error documents, favicon.ico, or robots.txt
RewriteCond %{REQUEST_URI} !^/wiki/(stylesheets|images)/
RewriteCond %{REQUEST_URI} !^/wiki/(redirect|texvc|index).php
RewriteCond %{REQUEST_URI} !^/error/(40(1|3|4)|500).html
RewriteCond %{REQUEST_URI} !^/wiki/favicon.ico
RewriteCond %{REQUEST_URI} !^/robots.txt

# Make sure there is no query string. /Adrian
# This gives "badly formed search query".
# gets /wiki/Special:Search?search=somequery&go=Go instead of
#      /wiki/index.php?search=somequery&go=Go
RewriteCond %{QUERY_STRING} ^$ [OR] RewriteCond %{REQUEST_URI} ^/wiki/Special:Search


# Rewrite any article as wiki/index.php/article and stop
RewriteRule ^(.*)$                      index.php?title=$1 [L]
------------



More information about the MediaWiki-l mailing list