3

I've recently come across some strange behaviour of my Joomla 3.6.5 installation. I've noticed that (with SEF on) any article preceded by its ID is displayed if called directly by its URL, and not only by following the path laid out in the menu item.

For example, if according to the menu item, the correct path would be:

domain.com/menu-item1/submenu-item/219-article-title

the article shows up under any menu item and even without it. So

domain.com/219-article-title

or

domain.com/menu-item2/219-article-title

return the body of the article. In these cases, however, the title set through the menu item is maintained, only the the text of the article is rendered. Interestingly enough, only the part after the 'read more...'

When I switch off SEF, the behaviour is the same when I replace the article's ID an title in the URL.

I find this behaviour rather peculiar. It is causing me some trouble, as the Google crawler indexes these pages. As I run a multi-site installation, some articles of one site appear in the vest of the other (and can be accessed via Google search), which is rather annoying.

Is there a way to prevent that from happening and displaying the articles only according to the setting in the menu item?

1

1 Answer 1

2

This is a problem with the Joomla content router. Specifically, in the following code:

if (!$advanced)
{
    $cat_id = (int) $segments[0];

    $article_id = (int) $segments[$count - 1];

    if ($article_id > 0)
    {
        $vars['view'] = 'article';
        $vars['catid'] = $cat_id;
        $vars['id'] = $article_id;
    }
    else
    {
        $vars['view'] = 'category';
        $vars['id'] = $cat_id;
    }

    return $vars;
}

You can see how the $article_id is an integer cast of the last part of the $segments array. This means that you can have something like: [youjoomladomain].com/blablabla/123-your-article.html, and the link will still work, despite the fact that blablabla doesn't even exist anywhere (not even as a category or a menu item). Even [youjoomladomain].com/blablabla/123-blablabla.html will work, because 123 is an existing article ID (so, everything else is ignored). This is a big problem from an SEO perspective, because a spammer can just link to the same article on your website from multiple URLs (where the middle part can be an obscene string).

The clean solution to this problem is to use the sef_advanced_link as described here. The sef_advanced_link option is not well promoted in Joomla (it's not even an option from within the backend - at least the last time I checked), despite its huge benefits (I really have no idea why). By using this option, you will get rid of the ID in the string, so Joomla is forced to check the whole URL in order to know which article you are referring to. Once enabled, any "blablabla" in the middle of the URL will return a 404.

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.