Topic on Project:Support desk

Short URL not working as expected

3
176.182.111.164 (talkcontribs)

I have an issue with short URLs, despite trying to follow the guide there.

My server is running Ubuntu 22.04.1 "jammy" and can be reached at https://ornans.wiki. I installed MediaWiki with apt install mediawiki and have the following software versions:

- dpkg -s mediawiki | grep Version returns Version: 1:1.35.6-1

- apache2 -v returns Server version: Apache/2.4.52 (Ubuntu)

- mysql --version returns mysql  Ver 8.0.30-0ubuntu0.22.04.1 for Linux on x86_64 ((Ubuntu))


My MediaWiki install is located at /var/lib/mediawiki/ (so this is the location of my LocalSettings.php) and I made a symlink from /var/www/html to that folder (with the command ln -s /var/lib/mediawiki /var/www/html).

In my LocalSettings.php, wgScriptPath is set to "/mediawiki".


My Apache HTTPS config, located at /etc/apache2/sites-available/000-default.conf is:

<VirtualHost *:80>

ServerAdmin webmaster@localhost

DocumentRoot /var/www/html

ErrorLog ${APACHE_LOG_DIR}/error.log

CustomLog ${APACHE_LOG_DIR}/access.log combined

RewriteEngine on

RewriteCond %{SERVER_NAME} =www.ornans.wiki [OR]

RewriteCond %{SERVER_NAME} =ornans.wiki

RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

# Short URL for wiki pages

RewriteRule ^/?w(/.*)?$ %{DOCUMENT_ROOT}/mediawiki/index.php [L]

# Redirect / to Main Page

RewriteRule ^/*$ %{DOCUMENT_ROOT}/mediawiki/index.php [L]

</VirtualHost>


The HTTPS config, located at /etc/apache2/sites-available/000-default-le-ssl.conf is:

<IfModule mod_ssl.c>

<VirtualHost *:443>

any further virtual host explicitly.

ServerAdmin webmaster@localhost

DocumentRoot /var/www/html

ErrorLog ${APACHE_LOG_DIR}/error.log

CustomLog ${APACHE_LOG_DIR}/access.log combined

Alias /w /var/lib/mediawiki/index.php

# Enable the rewrite engine

RewriteEngine On

# Redirect / to Main Page

RewriteRule ^/*$ %{DOCUMENT_ROOT}/mediawiki/index.php [L]

ServerName www.ornans.wiki

Include /etc/letsencrypt/options-ssl-apache.conf

ServerAlias ornans.wiki

SSLCertificateFile /etc/letsencrypt/live/www.ornans.wiki/fullchain.pem

SSLCertificateKeyFile /etc/letsencrypt/live/www.ornans.wiki/privkey.pem

</VirtualHost>

</IfModule>


I would like my wiki to be accessed at w, without any browser URL rewriting. This means that I would like to write ornans.wiki/w/My_Page and it should show the page "My Page" while the URL displayed in the URL bar in the browser stays the same.

Does anyone know what I need to change in order for my MediaWiki install to work as I expect?

Bawolff (talkcontribs)

Your apache config looks fine.

I think that your $wgArticlePath in LocalSettings.php is wrong. Try setting it to '/w/$1'

176.164.252.138 (talkcontribs)

Thanks, I was sure I had tried that but it hadn't worked. Everything works fine now :)

Reply to "Short URL not working as expected"