If you really want to close out visitors from users pages, then maybe you can also create a system plugin and onAfterroute
event you could use something like the following code:
public function onAfterRoute()
{
if ($this->app->getRouter()->getVar('option') === 'com_users')
{
$guestRedirectUrl = '/index.php';
$this->app->redirect($guestRedirectUrl, $status = 303);
}
}
(if you use it on a live webserver, the leading slash is not needed in the redirect url).
Or another version, as @Sharky has suggested, the following is more effective on sef urls:
if ($this->app->input->get('view') === 'registration')
{
// let's redirect...
}
This is just a sudden idea on this, instead of using .htaccess for redirect. From the router you can get Itemid
or view
too, so it can work on more precise condition too like:
if ($this->app->getRouter()->getVar('view') === 'registration')
and on many other versions of conditions. if sef urls are used this will not work on those pages, however this will:
$pagevars = $this->app->getRouter()->getVars();
if ($pagevars['option'] === 'com_users' && $pagevars['Itemid'] === '437')
{
// do redirect...
}
(Itemid should be changed to your registration page's Itemid of course).
(Itemid and option (component name) is available via router too even if someone uses sef urls).
Sidenote: creating a plugin for these kind of small tasks sounds quite stupid, but it is not if you can/would later use this same custom system plugin of yours to do few other things on your site via a system plugin. It comes handy at those times too.