No Code Attached Yet
avatar joeforjoomla
joeforjoomla
19 Aug 2025

Steps to reproduce the issue

Open a URL with index.php

Expected result

All works

Actual result

404 page unless index.php is omitted

Image Image
avatar joeforjoomla joeforjoomla - open - 19 Aug 2025
avatar joomla-cms-bot joomla-cms-bot - change - 19 Aug 2025
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 19 Aug 2025
avatar joeforjoomla
joeforjoomla - comment - 19 Aug 2025

The issue also affects the POST method

avatar joeforjoomla
joeforjoomla - comment - 19 Aug 2025

Incriminated code (damn modifications to language router, each time problems):

`public function parseRule(&$router, &$uri)
{
// Are we in SEF mode or not?
if ($this->mode_sef) {
$path = $uri->getPath();
$parts = explode('/', $path);
$sef = StringHelper::strtolower($parts[0]);
$lang = $uri->getVar('lang');

        if (isset($this->sefs[$sef])) {
            // We found a matching language to the lang code
            $uri->setVar('lang', $this->sefs[$sef]->lang_code);
            array_shift($parts);
            $uri->setPath(implode('/', $parts));

            // We were called with the default language code and want to redirect
            if ($this->params->get('remove_default_prefix', 0) && $uri->getVar('lang') == $this->default_lang) {
                $router->setTainted();
            }
        } elseif ($this->params->get('remove_default_prefix', 0)) {
            // We don't have a prefix for the default language
            $uri->setVar('lang', $this->default_lang);
        } else {
            // No language is set, so we want to redirect to the right language
            $router->setTainted();
        }

        // The language was set both per SEF path and per query parameter. Query parameter takes precedence
        if ($lang) {
            $uri->setVar('lang', $lang);
            $router->setTainted();
        }
    } elseif ($uri->hasVar('lang')) {
        // We are not in SEF mode. Do we have a language set?
        $lang_code = $uri->getVar('lang');

        if (isset($this->sefs[$lang_code])) {
            // We found a matching language to the lang code
            $uri->setVar('lang', $this->sefs[$lang_code]->lang_code);
        } else {
            // The language is not installed on our site
            $uri->delVar('lang');
        }
    }
}

/**
 * Parse rule to set the applications language state.
 * This rule is removed after being executed the first time, since
 * it does redirects and thus disallows parsing more than one URL per page call
 *
 * @param   Router  &$router  Router object.
 * @param   Uri     &$uri     Uri object.
 *
 * @return  void
 *
 * @since   6.0.0
 */
public function setLanguageApplicationState(&$router, &$uri)
{
    // We check if the parseRule is still attached to keep this b/c
    if (!\in_array([$this, 'parseRule'], $router->getRules()['parsepreprocess'])) {
        $router->detachRule('parse', [$this, 'setLanguageApplicationState'], $router::PROCESS_BEFORE);

        return;
    }

    $lang_code = false;

    // Our parse rule discovered a language
    if ($uri->hasVar('lang')) {
        $lang_code = $uri->getVar('lang');
    } else {
        /**
         * We don't know the language yet and want to discover it.
         * If we remove the default prefix, call by POST or have nolangfilter set,
         * we simply take the default language.
         */
        if (
            $this->params->get('remove_default_prefix', 0)
            || $this->getApplication()->getInput()->getMethod() === 'POST'
            || $this->getApplication()->getInput()->get('nolangfilter', 0) == 1
            || \count($this->getApplication()->getInput()->post) > 0
            || \count($this->getApplication()->getInput()->files) > 0
        ) {
            $lang_code = $this->default_lang;
        } else {
            $lang_code = $this->getLanguageCookie();

            // No language code. Try using browser settings or default site language
            if (!$lang_code && $this->params->get('detect_browser', 0) == 1) {
                $lang_code = LanguageHelper::detectLanguage();
            }

            if (!$lang_code) {
                $lang_code = $this->default_lang;
            }

            if (!$this->params->get('remove_default_prefix', 0) && $uri->getPath() == '') {
                if ($this->mode_sef) {
                    $path = $this->lang_codes[$lang_code]->sef . '/' . $uri->getPath();

                    if (!$this->getApplication()->get('sef_rewrite')) {
                        $path = 'index.php/' . $path;
                    }

                    $uri->setPath($path);
                } else {
                    $uri->setPath('index.php');
                    $uri->setVar('lang', $this->lang_codes[$lang_code]->sef);
                }
                $redirectHttpCode = 301;
                $redirectUri      = $uri->base() . $uri->toString(['path', 'query', 'fragment']);

                // We cannot cache this redirect in browser. 301 is cacheable by default so we need to force to not cache it in browsers.
                $this->getApplication()->setHeader('Expires', 'Wed, 17 Aug 2005 00:00:00 GMT', true);
                $this->getApplication()->setHeader('Last-Modified', gmdate('D, d M Y H:i:s') . ' GMT', true);
                $this->getApplication()->setHeader('Cache-Control', 'no-store, no-cache, must-revalidate', false);
                $this->getApplication()->sendHeaders();

                // Redirect to language.
                $this->getApplication()->redirect($redirectUri, $redirectHttpCode);
            }
        }
    }

    // We have found our language and now need to set the cookie and the language value in our system
    $this->current_lang = $lang_code;

    // Set the request var.
    $app = $this->getApplication();
    $app->getInput()->set('language', $lang_code);
    $app->set('language', $lang_code);
    $language = $app->getLanguage();

    if ($language->getTag() !== $lang_code) {
        $language_new = $this->languageFactory->createLanguage($lang_code, (bool) $app->get('debug_lang'));

        foreach ($language->getPaths() as $extension => $files) {
            if (str_starts_with($extension, 'plg_system')) {
                $extension_name = substr($extension, 11);

                $language_new->load($extension, JPATH_ADMINISTRATOR)
                || $language_new->load($extension, JPATH_PLUGINS . '/system/' . $extension_name);

                continue;
            }

            $language_new->load($extension);
        }

        Factory::$language = $language_new;
        $app->loadLanguage($language_new);
    }

    // Create a cookie.
    $this->setLanguageCookie($lang_code);

    $router->detachRule('parse', [$this, 'setLanguageApplicationState'], $router::PROCESS_BEFORE);
}`
avatar joeforjoomla
joeforjoomla - comment - 19 Aug 2025
avatar joeforjoomla
joeforjoomla - comment - 19 Aug 2025

So definitely #43858 DOES NOT work

avatar LadySolveig
LadySolveig - comment - 20 Aug 2025

@Hackwar could you please have a look.

avatar Fedik
Fedik - comment - 23 Aug 2025

I not sure what is going on with 404, but can you please check #45947 whether it fixes the issue by accident? thanks

Add a Comment

Login with GitHub to post a comment