Extension:ImageProtection

Overview
One of our MediaWiki-based research projects requires login to mediaWiki to read article content. It also needs to prevent people who have not logged in from being able to access documents and images that are uploaded into the filesystem accessible though the Image:, and Media: namespaces. This extension addresses the second of these issues.

Installation
Add this line to your LocalSettings.php:

Copy this code and create a file inside the extensions directory called ImageProtection.php.

Create an .htaccess file inside the images directory in your wiki. Apache will need to have the directive AllowOverride All set for the images directory so it will read and execute the .htaccess file.

.htaccess file: RewriteEngine On RewriteRule ^(.*)$ /wiki/index.php?action=image&image=$1 [L] [QSA]

You will need to change or remove /wiki from the RewriteRule depending on the path of your installation.