diff --git a/.envrc.sample b/.envrc.sample index bc76a8f..357cd22 100644 --- a/.envrc.sample +++ b/.envrc.sample @@ -11,4 +11,5 @@ export MEDIAWIKI_EMAIL_FROM="wiki@wiki.example.com" export DB_ROOT_PASSWORD_VERSION=v1 export DB_PASSWORD_VERSION=v1 export LOCAL_SETTINGS_CONF_VERSION=v1 +export HTACCESS_CONF_VERSION=v1 export ENTRYPOINT_CONF_VERSION=v1 diff --git a/LocalSettings.php.tmpl b/LocalSettings.php.tmpl index bc28fb7..74a52c0 100644 --- a/LocalSettings.php.tmpl +++ b/LocalSettings.php.tmpl @@ -29,6 +29,8 @@ $wgMetaNamespace = "{{ env "MEDIAWIKI_SITENAMESPACE" }}"; ## https://www.mediawiki.org/wiki/Manual:Short_URL $wgScriptPath = ""; +$wgArticlePath = "/wiki/$1"; + ## The protocol and server name to use in fully-qualified URLs $wgServer = "https://{{ env "DOMAIN" }}"; diff --git a/compose.yml b/compose.yml index cafb686..99c5e97 100644 --- a/compose.yml +++ b/compose.yml @@ -37,6 +37,8 @@ services: configs: - source: LocalSettings_conf target: /var/www/html/LocalSettings.php + - source: htaccess_conf + target: /var/www/html/.htaccess - source: entrypoint2_conf target: /docker-entrypoint2.sh mode: 0555 @@ -81,7 +83,11 @@ configs: name: ${STACK_NAME}_local_settings_${LOCAL_SETTINGS_CONF_VERSION} file: LocalSettings.php.tmpl template_driver: golang + htaccess_conf: + name: ${STACK_NAME}_htaccess_${HTACCESS_CONF_VERSION} + file: htaccess.tmpl + template_driver: golang entrypoint2_conf: name: ${STACK_NAME}_entrypoint2_${ENTRYPOINT_CONF_VERSION} - file: entrypoint.sh + file: entrypoint.sh.tmpl template_driver: golang diff --git a/entrypoint.sh b/entrypoint.sh.tmpl similarity index 97% rename from entrypoint.sh rename to entrypoint.sh.tmpl index 1ce4733..0845c31 100755 --- a/entrypoint.sh +++ b/entrypoint.sh.tmpl @@ -20,6 +20,8 @@ init_db() { main() { set -eu + a2enmod rewrite + init_db } diff --git a/htaccess.tmpl b/htaccess.tmpl new file mode 100644 index 0000000..c5116e7 --- /dev/null +++ b/htaccess.tmpl @@ -0,0 +1,12 @@ +# Generated using https://shorturls.redwerks.org + +RewriteEngine On +RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/index.php [L] + +RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f +RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d +RewriteRule ^/?images/thumb/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ %{DOCUMENT_ROOT}/thumb.php?f=$1&width=$2 [L,QSA,B] + +RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f +RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d +RewriteRule ^/?images/thumb/archive/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ %{DOCUMENT_ROOT}/thumb.php?f=$1&width=$2&archived=1 [L,QSA,B]