0

Today I caught a bug with my 404 page redirecting.

If I have not existing page like this https://domain.com/blablapage, redirecting to 404 is working all good.

But if user go to url https://domain.com/blablapage/onemorepage, Joomla not redirecting him to 404, but open main page with any of menu item.

My custom error.php starting with:

if (($this->error->getCode()) == '404') {
    header('Location: ' . JRoute::_('index.php?option=com_content&view=article&id=53')); // Url to 404 page
    exit;
}
4
  • It would be best to report discovered bugs directly to the Joomla maintainers. Commented Oct 11, 2022 at 21:26
  • Unable to reproduce the behaviour in Joomla 3.10.11. The URL domain.com/blablapage/something is redirected to a 404 page.
    – toivo
    Commented Oct 11, 2022 at 22:30
  • @user3774771 We are going to Need More Debugging Details with this question. If we cannot reproduce the issue, this page will need to closed as Unclear/Cannot Be Reproduced. Commented Oct 12, 2022 at 1:57
  • I tried to emulate problem on working domain. And type of problem is changed: when I type acciostore.kz/23fr23f2g (is not existing page), I get not 404, but some existing article in component block Commented Oct 12, 2022 at 16:39

2 Answers 2

3

This is a well known issue and can be considered as expected behavior for the time being. Basically, the URL path segment is cast to an integer somewhere in the component's router. So 23fr23f2g becomes 23 and a content item with ID 23 is loaded. Some patches to fix the issue have been proposed but haven't made it to core yet. There might some SEF extensions available that solve the issue.

1

Are you sure that the corresponding MenuItem exists?

The above header() function needs the url taken from the MenuItem itself.

So you need one article and one menu item (hidden).

To test if it works, just go to your Menu, go in to the menuitem like 'about/whateverYouLike', then copy the full path from the URL field (detail view tab) and paste to your JRoute().

The url has form of "index.php?option=com_content&view=article&id=3" and must exist in MenuItem tree.

3
  • It is important to clarify the details within the question instead of posting an answer to ask for more details or making assumptions about the question's details. Please request clarifications by posting comments under the question. Commented Oct 12, 2022 at 1:59
  • How am i supposed to make a comment for more information when i can't make comments until 50rep. I must place an answer to comment my own content then.
    – Elboyler
    Commented Oct 15, 2022 at 22:21
  • Yes, it is an unfortunate/irritating barrier for new contributors. You are not the first to make this argument (nor will you be the last). The official response is to encourage you to answer any of the other thousands of clear and complete questions with good, unique, educational answers to earn the necessary rep to unlock the privilege. Commented Oct 15, 2022 at 22:58

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.