Suppose a menu's (or article's) access is set to registered users only.

Path to the page : http://localhost/menu

when this URL is directly access by any GUEST USER, he's redirected to :

http://localhost/...?view=login which asks him to login first.

How to change the path to redirect page..i have made a custom login page, i want it to be redirected to my custom made login page and not to http://localhost/...?view=login. Which file needs to be edited to acheive that?

  • This should do the job extensions.joomla.org/extensions/access-a-security/site-access/… I have used it and works
    – jonboy
    Jun 18, 2014 at 8:16
  • Nope, it didn't work!
    – saibbyweb
    Jun 19, 2014 at 6:46
  • I looked everywhere for a solution to this issue. I have a custom login menu/page and wanted anyone (guest, etc) directed there. This variable view=login was redirecting users to some template and I tried everything, even hacking it together. This solution above by @Saibbyweb is so simple and does the trick. (If necessary, simply copy the PHP files to the folder YOUR_TEMPLATE/html/com_users/login) then modify as stated above....it worked like a charm!! Thank you!!
    – user2190
    Nov 12, 2014 at 22:46

5 Answers 5


I figured it out myself! :)

You need to edit this file : /templates/your_template/html/com_users/login/default.php or if your template folder doesn't consist of html folder, edit this one: /components/com_users/views/login/tmpl/default.php

and change

if ($this->user->get('guest')):
echo $this->loadTemplate('login');


if ($this->user->get('guest')):

If you would like to make your login page look different, you can do a template override and no need to redirect to a different page. Find your templates folder and select the template you are using. Create an html folder if you do not have one. The component you wanna override is com_users.

If you have a look at /components/com_users/views folder, you can see all the views that can be overriden in the template folder. The one we need now is in the login folder. /components/com_users/views/login/tmpl - there are default.php default_login.php and default_logout.php.

You have already created an html folder in your template, now you need to copy these files in the following location:


That will result in having 3 files:


You do not need the tmpl folder.

You can edit the default_login.php to do the override.

  • i have already customized my site alot! i just need to change the redirect path..otherwise i need to make changes in around 50-60 pages :/
    – saibbyweb
    Jun 18, 2014 at 17:11

You need to create a plugin, which will check the url and Usergroup. If you user is guest then you can redirect user to desired url.

Below link may help you.


The answer by @saibbyweb resulted in an infinite redirect loop in Joomla 3.9.

I then figured out that my problem was with the component I was trying to access, com_akeebasubs, which used:

$this->container->platform->redirect(\JUri::base() .'index.php?option=com_users&view=login&return=' . $myURI);

The redirect worked properly after I changed this line to:

$this->container->platform->redirect(\JRoute::_('index.php?option=com_users&view=login&return=' . $myURI));

You do need to have a User > Login Form menu item.

  • Thank you for contributing. Please take the tour and perhaps tell us about yourself by editing your profile. I look foward to seeing more of your insights shared. Dec 5, 2019 at 20:01

If you wanna change where the user is going to be redirected after login and logout, you van do this in the login module of joomla. There are 2 fileds for this.

  • when the user is detected as guest, he's directed to the login page http://localhost/...?view=login (which say please login first) , i want to change that URL
    – saibbyweb
    Jun 19, 2014 at 6:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.