I want to redirect a user to the homepage of my joomla website and that he must not be able to go back in the browser.absolutely not.

I tried many things in regards to this but couldn't accomplish it.

How do i stop going back and redirect the user to the homepage.

P.S i have a login module that has a parameter logout redirect page : have set it to the homepage menu that appears in the checkbox.

doesn't work.

  • The issue is that the back button basically just pulls from the cache. If the page actually was refreshed, it would show they don't have access to that page. Probably would have to implement something like this: stackoverflow.com/questions/829046/… Feb 2, 2015 at 17:01

2 Answers 2


It seems that you want non-logged in users to access only homepage of your site.

Obviously if you redirect them on logout then user can always go back to any other url.

What i suggest, you should create a system plugin for this which will check whether user is logged in or not. And if user is not logged in then redirect him to the homepage.

You can apply this checking on joomla event onAfterRoute()

function onAfterRoute()
  $userId = JFactory::getUser()->id;
  //if user is not logged-in redirect to home-page


For joomla plugin creation you can refer these tutorials

Plugin Development

Creating Plugin for Joomla

  • No i don't want non-logged in users to access only homepage of my site.I want them to access all of the urls. The only problem is with logged in users.what i intend to do is that the user who has logged out must not be able to go back so as he is not able to access the privileges again ( which won't work after session is cleared ) - the point is my auditor doesn't want the user be allowed to go back and the " edit " option for the articles be shown to him. Feb 2, 2015 at 16:22
  • well for this you should check whether user is logged-in or not prior to providing access to privileged section
    – Nick
    Feb 2, 2015 at 16:41
  • that the login module does itself.i just want that when he logouts he must not be able to go back.thats it precisely. Feb 2, 2015 at 16:49

It's not a very beautiful thing, but I think it may work:

Step 1:

On logout redirect the user to your home page, adding just a little $_GET variable. Redirect Link should be


Step 2:

Insert, into this page or your Joomla Template index.php, a script that will prevent the back button from functioning whenn the variable $_GET['logged_out'] is set. This part is really tricky, because no method to my knowledge will actually work in every situation. The easiest way to disable the back button is IMO to actually fool it:

    if (isset($_GET["logged_out"])){
       echo '<script type="text/javascript">window.location.replace('.JURI::base().');</script>';

This will redirect the user to your home page another time. As I said, it is not very beautiful, but I doubt that there are beautiful ways to do at all. In fact, I would strongly suggest to evaluate if this is truly necessary.

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.