Manual:$wgWhitelistRead

Details
If a group of users is blocked from viewing the wiki by using the $wgGroupPermissions setting... ...you may still want them to be able to view certain key pages, in particular the login page! This setting holds an array of page names that all users are allowed to view, regardless of their group permissions.

A recommended minimum is as follows: (Note that "Main Page" above uses spaces instead of underscores between words.) This allows everyone to view the home page and the login screen. You may also want to include other pages such as help/about/contact pages.

Anonymous users can only view: Special:Userlogin
Anonymous users cannot read or edit any other page, but can still create accounts: To additionally block account creation by anonymous users, add the following line: With anonymous account creation disabled, sysops will need to create accounts for new users manually (or a LDAP extension is used for authentification)

Anonymous users cannot read anything on the Wiki except a page you re-direct them to
The above instruction doesn't cover what to do if you don't even want the anonymous user to view the Main Page, but still want to pass a message along to the user. You can technically "hide" your entire Wiki using this, with a nice friendly message.

A nifty trick if you wish to force visitors to always log in before being able to view or do anything on your Wiki, but still give them instruction on how to access the Wiki, etc:

1. Create a template page called "Template:Guest View" (this can be called whatever), and put some text in the page explaining why they can't view the page, etc.

2. Add the following to your LocalSettings.php 3. Whatever languages your Wiki uses, edit the "languages/messages/MessagesXX.php" (where XX = language, i.e. MessagesEn.php)

4. Find in the file 5. And replace with

This will then display not only the "You must log in", but will also give whatever information you wish to pass along with to the anonymous user in Wiki format. Sure, you can easily search for and add to or replace the 'loginreqpagetext' with this information, but now other sysops and users you designate template modification access can modify this page through the Wiki without the need to edit shell files.