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
redirect if wrong url to: /error-404.html
in J3 worked
blog-detail page: wrong url -> redirect to /error-404.html
all other pages: redirect with code 200 to mainpage - no error.
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; } } ?>Labels |
Added:
No Code Attached Yet
|
I can't confirm this issue while using Joomla 4 core installation:
JoomlaRoot/error-404.html
Blaubbbbbbbb Balb Blabbbb
<?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;
}
}
Blaubbbbbbbb Balb Blabbbb
in browser => redirection to error-404.html
works.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.
Changed my test case:
error
(first level menu item). Hidden in menus.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;
}
}
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.
Which mail?
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2021-11-19 09:41:45 |
Closed_By | ⇒ | Fedik |
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.
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.
I had the same situation, hope you can fix it. @joomla-cms-bot