Joomla 在尝试访问受保护的文章时创建/引发 403 事件。因此编辑文件 System / error.php 或在模板本身内不起作用。 .htaccess 或 httpd.conf 中使用 ErrorDocument 的其他解决方案也不起作用。
我也试过代码 this-> error-> getCode () == '403',但没有触发。
我找到的唯一解决方案是修改文章的 HTML 视图,以重定向到显示登录名和个性化消息的文章。
要修改的文件是components/com_content/views/article/view.html.php第134到139行
Joomla 3.9.20
要替换的代码如下:
// Check the view access to the article (the model has already computed the values).
if ($ item-> params-> get ('access-view') == false && ($ item-> params-> get ('show_noauth', '0') == '0'))
{
$ app-> enqueueMessage (JText :: _ ('JERROR_ALERTNOAUTHOR'), 'error');
$ app-> setHeader ('status', 403, true);
return;
}
为此
// Check the view access to the article (the model has already computed the values).
if ($item->params->get('access-view') == false && ($item->params->get('show_noauth', '0') == '0'))
{
header('Location:https://www.yourwebpage/withLoginandCustomMessage.php');
die();
}
这只会向尝试查看需要注册或使用其他 ACL 的文章的用户显示。
我知道我们不应该编辑文件,因为在 Joomla 更新中,这些更改可能会丢失,但这是我找到的唯一解决方案(模块或插件都没有解决这个问题,显然它是来自joomla 1.5)。