In Joomla 3.5.1, I want to redirect users to the page they were before logging in.

If they login from mod_login, no problem, since the module is pending from the top menu, they just stay at that page.

The problem happens when the users login from the component: they are always redirected to the profile page.

In the menu item index.php?option=com_users&view=login there's an option to redirect users after login.

But how do I tell: "Get them back to the page they were before"?

Certain components are appending something like:


To the URL, requesting a redirect to a specific page.

But they always go back to the profile page.

  • they always go back to the profile page. it happens to me, regardless of modifying as @Lodder suggested.
    – kokbira
    Commented Nov 28, 2017 at 14:23

2 Answers 2


Quite simple to do this.

You will firstly need to create a Template Override for the following file:


Once done, open the following file (your override):


and go to line 81, where you will see the following code:

<input type="hidden" name="return" value="<?php echo base64_encode($this->params->get('login_redirect_url', $this->form->getValue('return'))); ?>" />

and replace it with:

<input type="hidden" name="return" value="<?php echo base64_encode($_SERVER['HTTP_REFERER']); ?>" />

Hope this helps

  • +1 Very nice idea. I'm not sure if the $_SERVER['HTTP_REFERER'] is always a valid choice, but I like the idea . Commented Apr 12, 2016 at 13:47
  • @mavrosxristoforos - Yeah it does have some drawbacks. A more advanced and reliable solution would involve a system plugin, making use of a session or cookie
    – Lodder
    Commented Apr 12, 2016 at 13:58
  • Thanks a lot for helping, I've been using template overrides for K2 for years but for core joomla it seems impossible. I did look at the instructions in your link, including the "Creating overrides" section but whatever changes I do are ignored. Commented Apr 12, 2016 at 14:14
  • @NunoNogueira - The file you open to make the changes to, does the path match what I've provided in my answer (2nd code snippet)? It should be exactly the same, apart from MY_TEMPLATE which of course is the name of your template
    – Lodder
    Commented Apr 12, 2016 at 14:15
  • @NunoNogueira - I made a mistake with the path, I've updated it now. (remove /view/)
    – Lodder
    Commented Apr 12, 2016 at 14:17

Do not create any login menu. This way it redirects automatically to the last page requested and attempts to login. For the same page, then use a guest page to a restricted page or you can use a login redirect to the same page.

Your Answer

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

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