Search code examples
apachemod-rewritemediawikisubdirectory

Mediawiki Subdirectory Installation


Possible Duplicate: MediaWiki on SubDirectory and SubDomain (However doesn't have an answer, nor any replies offering help)

Alright, I'm trying to configure MediaWiki to be installed to a sub-directory. I previously had it installed to a primary domain on http://www.example.com/ with a mod_rewrite using a Short URL of /wiki/Main_Title.

As a note, I'm also on HostGator shared hosting which has special rules for short urls.

My directory structure is as such:

  • / (site root; location of .htaccess)
  • /wiki/ (mediawiki root; location of LocalSettings.php)

Here's what I tried,

.htaccess:

RewriteEngine on
RewriteBase /
RewriteRule ^(.*)\&(.*)$ $1\%26$2
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^wiki/(.+)$ ./wiki/index.php?title=$1 [PT,L,QSA]

/wiki/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       = "/wiki";
$wgScriptExtension  = ".php";
$wgArticlePath      = "$wgScriptPath/$1";

However, I do not get anything. I simply get a 403/Forbidden error; no 500 Internal Server Error, just a 403 - url http://www.example.com/. It's as if there's nothing being done. I've banged my head against the wall trying to figure this out. Any help is appreciated.

Thanks in advance!


Solution

  • My ticket to HostGator resolved the issue, albeit un-helpfully. I was hoping for a single .htaccess solution, rather than a double .htaccess redirect/rewrite. However, here's my solution.

    /:

    RewriteEngine on
    RewriteCond %{REQUEST_URI} ^/$
    RewriteRule ^.*$ http://www.example.com/wiki/
    

    /wiki/:

    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.+)$ index.php?title=$1 [L,QSA]