2

I have trouble with links in joomla 3.8. I have link like http://mysite.loc/my-category/my-subcategory/89 and this is correct link for material with id 89. But when i enter http://mysite.loc/my-category/my-subcategory/89asdasdasdasd Joomla show me this page, and repsonce 200/ok. How can i handle this and show 404 error for URL's like this ? SEF Is turned on

andreas
  • 16,357
  • 12
  • 72
  • 76
Sergey Smekodub
  • 92
  • 1
  • 1
  • 13

2 Answers2

0

Yes - this is how Joomla behaves. When you have something like yoursite.com/my-category/123-blablabla, Joomla will load the article having 123 as an ID. In fact, the article with ID 123 doesn't even have to be in the my-category category. This is one of the weird things in Joomla.

The solution to this problem is to remove the article ID from the URL as described here. Keep in mind 2 things though: 1) this is a core modification, and 2) the instructions on how to do so may be slightly different for 3.8.+.

itoctopus
  • 4,133
  • 4
  • 32
  • 44
0

I find solution its works for me. In class ContentRouterRulesLegacy find method parse, and where its call query to db to execute the article info put.

    $query = $db->getQuery(true)
                ->select($db->quoteName(array('alias', 'catid')))
                ->from($db->quoteName('#__content'))
                ->where($db->quoteName('id') . ' = ' . (int) $id,'AND')
                ->where($db->quoteName('alias') . ' = ' . "'$alias'");

            $db->setQuery($query);
            $article = $db->loadObject();

            if ($article)
            {
                if ($article->alias == $alias)
                {
                    $vars['view'] = 'article';
                    $vars['catid'] = (int) $article->catid;
                    $vars['id'] = (int) $id;

                    return;
                }
            }
            else
            {
                header('HTTP/1.0 404 Not Found');

                JError::raiseError(404, 'JGLOBAL_RESOURCE_NOT_FOUND');

                exit(404);
            }
Sergey Smekodub
  • 92
  • 1
  • 1
  • 13