Actually I also had to add a `RewriteCond %{REQUEST_FILENAME} ^/?images` to prevent /index.php from being broken.
My root .htaccess looks something like this now:
RewriteEngine on
# Protect against bug 28235 RewriteCond %{REQUEST_FILENAME} ^/?images RewriteCond %{QUERY_STRING} .[a-z0-9]{1,4}(#|?|$) [nocase] RewriteRule . - [forbidden]
# Thumbnail handler for image thumbnails RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(/?)images/thumb/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ $1thumb.php?f=$2&width=$3 [L,QSA]
# Thumbnail handler for archived images RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(/?)images/thumb/archive/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ $1thumb.php?f=$2&width=$3&archived=1 [L,QSA]
# Handler for 404 pages RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^/?.*$ /index.php?title=Special:Error404 RewriteRule ^(/?)images/thumb/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ $1thumb.php?f=$2&width=$3 [L,QSA]
I haven't figured out how to replicate that bug 28235 fix in Nginx though.
~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://daniel.friesen.name]
On 11-04-19 09:28 AM, Daniel Friesen wrote:
Using the rewrite inside images/.htaccess appears to conflict with existing installations with a root .htaccess including the code for the thumbnail handler.
You won't notice it right away because most images will already have existing thumbnails generated, but at some random point when someone.
In fact, I ONLY found out things were broken on any of my wiki after I created a brand new wiki with similar config and found I got 404s instead of thumbnails.
My fix was to comment out the code in images/.htaccess and add it to my root .htaccess. Of course I'll need to do something else on another one of my wiki that uses a separate domain for serving uploads.
~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://daniel.friesen.name]