Topic on Project:Support desk

Jump to navigation Jump to search

'404 Not Found' when accessing file pages on MediaWiki with short URLs configured

Quenhitran (talkcontribs)

Hi everyone,

I'm a long-term user of Wikimedia projects and recently I've engaged in setting up a wiki of my own. For reference, the URL to my wiki is

However, I'm running into issues when configuring Short URL on this wiki. The web server software is nginx; and as I followed the instructions on the page Manual:Short URL/Nginx, I managed to change the URL to a 'pretty' version for all pages EXCEPT for file pages. Whenever I go to a page in the file namespace, the site shows a '404 Not Found' message, as can be seen here:

I've tried multiple solutions that were suggested on previous posts of the Support desk, but none of them worked in my case.

I would appreciate all of your help on this matter, as it is a bit urgent for me to finish this site and bring it into operation.

Thank you.

Bawolff (talkcontribs)

can you include your full nginx config file.

You might have some other rule targeting images that messes up pages ending in .jpg.

Quenhitran (talkcontribs)

@Bawolff: Thank you very much for taking your time to help me. Here is the full nginx config file for my wiki site:

# Location for the wiki's root

# location /w/ {

## Do this inside of a location so it can be negated

# location ~ \.php$ {

# try_files $uri $uri/ =404; # Don't let php execute non-existent php files

# include /usr/local/src/centminmod/config/nginx/fastcgi_params;

# fastcgi_pass;

# }

# }

location /w/images/uploads/amswiki/ {

# Separate location for images/ so .php execution won't apply

location ~ ^/w/images/uploads/amswiki/thumb/(archive/)?[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ {

# Thumbnail handler for MediaWiki

# This location only matches on a thumbnail's url

# If the file does not exist we use @thumb to run the thumb.php script

try_files $uri $uri/ @thumb;



location /w/images/uploads/amswiki/deleted {

# Deny access to deleted images folder

deny all;


# Deny access to folders MediaWiki has a .htaccess deny in

location /w/cache       { deny all; }

location /w/languages   { deny all; }

location /w/maintenance { deny all; }

location /w/serialized  { deny all; }

# Just in case, hide .svn and .git too

location ~ /.(svn|git)(/|$) { deny all; }

# Hide any .htaccess files

location ~ /.ht { deny all; }

# Uncomment the following code if you wish to hide the installer/updater

## Deny access to the installer

#location /w/mw-config { deny all; }

# Handling for the article path

location /ams {

include /usr/local/src/centminmod/config/nginx/fastcgi_params;

# article path should always be passed to index.php

fastcgi_param SCRIPT_FILENAME $document_root/w/index.php;



# Thumbnail 404 handler, only called by try_files when a thumbnail does not exist

location @thumb {

# Do a rewrite here so that thumb.php gets the correct arguments

rewrite ^/w/images/uploads/amswiki/thumb/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ /w/thumb.php?f=$1&width=$2;

rewrite ^/w/images/uploads/amswiki/thumb/archive/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ /w/thumb.php?f=$1&width=$2&archived=1;

# Run the thumb.php script

include /usr/local/src/centminmod/config/nginx/fastcgi_params;

fastcgi_param SCRIPT_FILENAME $document_root/w/thumb.php;



Thank you again in advance!

Reply to "'404 Not Found' when accessing file pages on MediaWiki with short URLs configured"