Extension:NamespaceReadRestrict

If you need per-page or partial page access restrictions, you are advised to install an appropriate content management package. MediaWiki was not written to provide per-page access restrictions, and almost all hacks or patches promising to add them will likely have flaws somewhere, which could lead to exposure of confidential data. We are not responsible for anything being leaked, leading to loss of funds or one's job.For further details, see Security issues with authorization extensions

In accordance with the instructions at Manual:Preventing access, abolish the ability of non-logged-in users to read, edit or create accounts on your wiki and initialize the $wgWhitelistRead array (it must be initialized, even if it's empty, in order for this extension to work) by adding to your LocalSettings.php file the following:

Also add to LocalSettings.php, after the require_once line, this configuration setting specifying what namespaces are okay for non-logged-in users to read. E.g. in this example, non-logged-in users will only be allowed to read pages in namespace 0, the main namespace. See Manual:Namespace#Built-in_namespaces and Manual:Using custom namespaces.

If most of your wiki content will be open to the public, then you may want to establish a Private: namespace for the rest. Conversely, if you want most of your wiki to be private, then you might want to establish a Public: namespace for the rest. Don't forget about $wgNonincludableNamespaces, if you've left open the option of non-logged-in users to edit. E.g.:

There is a parser function, {{#isloggedin}}. If you also have Extension:ParserFunctions installed, then you can use this to, for example, give logged-in users and non-logged-in users different main pages. To do that, you would create pages "Template:Private main page" and "Template:Public main page" and then replace the content of "Main Page" with: