No Code Attached Yet
avatar DD-Webentwicklung
DD-Webentwicklung
17 Nov 2021

Steps to reproduce the issue

hidden menu -> error-404.html, link to sp pagebuilder page.

Custom Error php in template folder.
case for two languages de / en and default - if error 404 - redirect to /error-404.html

Expected result

redirect if wrong url to: /error-404.html
in J3 worked

Actual result

blog-detail page: wrong url -> redirect to /error-404.html
all other pages: redirect with code 200 to mainpage - no error.

System information (as much as possible)

all SEO-options enable.
Newest J4 release, Sp Pagebuilder.

error php:

error->getCode()) == '404') { switch ($lang->get('tag')){ case 'de-DE': header('Location: /error-404.html'); exit; break; case 'en-GB': echo 'en'; die(); break; default: header("Location: /error-404.html"); die(); break; } } ?>

Additional comments

avatar DD-Webentwicklung DD-Webentwicklung - open - 17 Nov 2021
avatar joomla-cms-bot joomla-cms-bot - change - 17 Nov 2021
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 17 Nov 2021
avatar michelwaechterimflow
michelwaechterimflow - comment - 17 Nov 2021

I had the same situation, hope you can fix it. @joomla-cms-bot

avatar ReLater
ReLater - comment - 18 Nov 2021

I can't confirm this issue while using Joomla 4 core installation:

  • Created file JoomlaRoot/error-404.html
Blaubbbbbbbb Balb Blabbbb
  • Changed error.php of cassiopeia to
<?php
defined('_JEXEC') or die;

use Joomla\CMS\Factory;

$app = Factory::getApplication();
$lang = Factory::getLanguage();

header("HTTP/1.0 404 Not Found");

if ($this->error->getCode() == '404')
{
    switch ($lang->get('tag')){
        case 'de-DE':
            header('Location: /error-404.html');
            die();
        break;
case 'en-GB':
            header("Location: /error-404.html");
            die();
        break;
        default:
            header("Location: /error-404.html");
            die();
        break;
    }
}
  • Entered a not existing URL in browser.
  • and see Blaubbbbbbbb Balb Blabbbb in browser => redirection to error-404.html works.
avatar DD-Webentwicklung
DD-Webentwicklung - comment - 18 Nov 2021

hidden menu -> custom error page with sp-pagebuilder. in J3 there was no need to put a error.html in root, just redirect to a link from joomla menu. this routing dont work in j4.

avatar ReLater
ReLater - comment - 18 Nov 2021

Changed my test case:

  • Created a Joomla menu item with alias error (first level menu item). Hidden in menus.

grafik

  • Changed SEO settings in configuration
    grafik

  • Adapted my code in error.php Because you told us in german forum that your Joomla is inside a subfolder without custom domain now with Uri.

<?php
defined('_JEXEC') or die;

use Joomla\CMS\Factory;
use Joomla\CMS\Uri\Uri;

$app = Factory::getApplication();
$lang = Factory::getLanguage();

header("HTTP/1.0 404 Not Found");

if ($this->error->getCode() == '404')
{
	switch ($lang->get('tag')){
		case 'de-DE':
			header('Location: ' . Uri::root(true) . '/error.html');
			die();
		break;
			header('Location: ' . Uri::root(true) . '/error.html');
			echo 'en';
			die();
		break;
		default:
			header('Location: ' . Uri::root(true) . '/error.html');
			die();
		break;
	}
}
  • redirection works as expected when I call an invalid url

grafik

  • So this seems not to be a Joomla 4 core issue.
avatar DD-Webentwicklung
DD-Webentwicklung - comment - 18 Nov 2021

i changed the subfolder to root. so the page is direct accessible. unicode aliase -> on please.
error.html or error-404.html.. simply dont matter. also tried the real link: index.php?option...
pls check mail.

avatar chmst
chmst - comment - 18 Nov 2021

Which mail?

avatar Fedik Fedik - change - 19 Nov 2021
Status New Closed
Closed_Date 0000-00-00 00:00:00 2021-11-19 09:41:45
Closed_By Fedik
avatar Fedik
Fedik - comment - 19 Nov 2021

To get correct routing to menu item use Route::_('index.php?Itemid=111') where 111 is ID of your menu item.

Please ask more for support on a forum.
I closing this, it not looks like Joomla issue, but some problem with your code.

avatar Fedik Fedik - close - 19 Nov 2021
avatar DD-Webentwicklung
DD-Webentwicklung - comment - 19 Nov 2021

i asked on a forum thx. seems nobody can explain routing in j4. code is posted so everybody can modify and test my code :) thx for closing. its a joomla issue cause: blog detail works, blog page not. needs just time till someone find the bad routing.. i'll wait.

Add a Comment

Login with GitHub to post a comment