Changing entry point URLs
-
Hi. I would like to remove the
/wiki/
in my site's URL:https:example.com/wiki/some_page
->https://example.com/some_page
I added two variables in
app/data/LocalSettings.php
:$wgArticlePath = '/$1'; $wgScriptPath = '/';
After a restart, the
https:example.com
landing page loads but without any CSS style. All other pages behind/wiki/
did not "move" and do not exist at the new URLs.On the mediawiki one step in the process is "Rename the installation directory of MediaWiki on your server from /wiki to /w [i.e. / in my case]." How can I do that ?
EDIT: with
$wgScriptPath = '';
the stylesheet is loaded. -
Hello @mononym
I have investigated this issue and found the following.According to my understanding after reading the documentation the
LocalSettings.php
should include the following:# Set the script path to root $wgScriptPath = ""; # Set the article path for pretty URLs $wgArticlePath = "/$1"; # If you're using a different entry point than index.php $wgScript = "/index.php"; # For resource loading $wgResourceBasePath = $wgScriptPath;
Just for good measure I also cleared the
Main Page
cache with:php maintenance/run.php purgePage <<< "Main Page"
But sadly, this did also not work.
So the only thing now breaking it could be the apache2 config and there it is.By default (not editable) - https://git.cloudron.io/packages/mediawiki-app/-/blob/master/apache/mediawiki.conf?ref_type=heads:
ServerName %{HTTP_HOST} <VirtualHost *:8000> DocumentRoot /app/code LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" proxy CustomLog "|/bin/cat" proxy ErrorLog "|/bin/cat" # https://www.mediawiki.org/wiki/Manual:Security php_flag register_globals off ## http://www.mediawiki.org/wiki/Manual:Short_URL/Apache RewriteEngine On RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/index.php [L] RewriteRule ^/*$ %{DOCUMENT_ROOT}/index.php [L] <Directory /app/code> Options +FollowSymLinks AllowOverride All Require all granted </Directory> # some directories must be protected # images/ still has to be accessible since mw references it directly <Directory /app/code/images> Options -FollowSymLinks AllowOverride None <IfModule mod_php7.c> php_admin_flag engine off </IfModule> </Directory> </VirtualHost>
I put the app into recovery mode and edited the Apache2 site file and changed the rewrite to the following:
RewriteEngine On RewriteCond %{REQUEST_URI} !^/rest\.php RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d RewriteRule ^(.*)$ %{DOCUMENT_ROOT}/index.php [L]
and started the app with
/app/pkg/start.sh
and got a working MediaWiki undersub.DOMAIN.tld/Main_Page
.
To make this usable for you and everyone else, an app update would be needed where users, like you, could also upload a custom Apache2 site setting file that will be included to overwrite the default one.
I am converting / hijacking this topic into a feature request.