8

I had a media wiki installation on the main directory /public_html/ of my domain and had short URLs enabled to http://example.org/wiki/Page_title so I had an .htaccess file with the following rules

# Enable the rewrite engine
RewriteEngine On

# Short url for wiki pages
RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/index.php [L]

# Redirect / to Main Page
RewriteRule ^/*$ %{DOCUMENT_ROOT}/index.php [L]

I want to install other applications in the main directory of that domain so I am trying to move this media wiki installation from the root /public_html/ directory to the /public_html/w/ while keeping the same short url format. So all I did was copy the content from the main directory to the /public_html/w/ directory and modify the .htaccess rules to

## http://www.mediawiki.org/wiki/Manual:Short_URL/Apache

# Enable the rewrite engine
RewriteEngine On

# Short url for wiki pages
RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/w/index.php [L]

# Redirect / to Main Page
RewriteRule ^/*$ %{DOCUMENT_ROOT}/w/index.php [L]

And also modify the LocalSettings.php file in the new directory from

$wgScriptPath = "";
$wgScriptExtension = ".php";
$wgArticlePath = "/wiki/$1";
$wgUsePathInfo = true;

to

$wgScriptPath = "/w";
$wgScriptExtension = ".php";
$wgArticlePath = "/wiki/$1";
$wgUsePathInfo = true;

In theory, since it's using the same db and all the same settings all I needed to change was the htaccess and localsettings.php directories and it should work fine but after I tried it I got a 500 server error and the site was not working at all and after I checked apache/php error logs I found a lot of the same stuff

[Sun Feb 28 13:59:14.477785 2016] [:error] [pid 12164] [client SERVER IP] script '/home/admin/web/MY DOMAIN/public_html/index.php' not found or unable to stat
[Sun Feb 28 13:59:21.854117 2016] [:error] [pid 12165] [client SERVER IP] script '/home/admin/web/MY DOMAIN/public_html/index.php' not found or unable to stat
[Sun Feb 28 13:59:32.073190 2016] [:error] [pid 12374] [client SERVER IP] script '/home/admin/web/MY DOMAIN/public_html/index.php' not found or unable to stat
[Sun Feb 28 13:59:33.574025 2016] [:error] [pid 12166] [client SERVER IP] script '/home/admin/web/MY DOMAIN/public_html/index.php' not found or unable to stat
[Sun Feb 28 13:59:35.873162 2016] [:error] [pid 12167] [client SERVER IP] PHP Warning:  require_once(/home/admin/web/MY DOMAIN/public_html/w/extensions/MsUpload/msupload.php): failed to open stream: No such file or directory in /home/admin/web/MY DOMAIN/public_html/w/LocalSettings.php on line 301
[Sun Feb 28 13:59:35.873207 2016] [:error] [pid 12167] [client SERVER IP] PHP Fatal error:  require_once(): Failed opening required '/home/admin/web/MY DOMAIN/public_html/w/extensions/MsUpload/msupload.php' (include_path='.:/usr/share/php:/usr/share/pear') in /home/admin/web/MY DOMAIN/public_html/w/LocalSettings.php on line 301

Notice the first errors are still referring to the previous root /public_html/ directory while the extensions errors are already referring to the /public_html/w/ directory

I have no clue where I went wrong here so I would appreciate some help. So far I had to revert the changes and restore a backup I had for the old directory but I still want to move the wiki directory.

spacing
  • 730
  • 2
  • 10
  • 41
  • You should do a grep on the files to see if there is somewhere a config file with the old path. Also you should look into the database and see if there are any other settings left. For instance wordpress uses wp_config.php to save some settings and the others it saves inside the database. – Radu Bogdan Mar 09 '16 at 10:38

3 Answers3

1

If you are still keeping /home/admin/web/MY DOMAIN/public_html/ as the root directory (as identified from the webserver) but, moving Mediawiki down a level, you might need to change the following:

RewriteBase /w/
Simon
  • 816
  • 2
  • 7
  • 16
0

There is no need to move media wiki from the currently operational location. As you are installing additional applications and media wiki already uses short URL's which makes accessing articles work using the form example.org/wiki/Article_Title what you can do is install the new applications in sub folders right along side the mediawiki installation without any issues at all, as the .htaccess rules will provide exceptions for files and folders which exist on the server.

Example folder structure

public_html /
    app1/
        index.php
        ...
    app2/
        index.php
        ...
    app3/
        index.php
        ...
    ... (all media wiki files and folders)
Chris Rutherfurd
  • 1,617
  • 1
  • 15
  • 32
0

I'm not familiar with MediaWiki, but given this comment:

Notice the first errors are still referring to the previous root /public_html/ directory while the extensions errors are already referring to the /public_html/w/ directory

I found the following comment on mediawiki.org:

If you redefine this [$wgScriptPath] in your LocalSettings.php then all dependent variables will need redefining too!

I'd investigate what else is set during installation time using this value, as that may be the cause of your issue.

CoderCreative
  • 225
  • 1
  • 2
  • 9