Ste*_*ugh 1 php joomla webserver http-status-code-403 http-status-code-404
您已经为joomla创建了一个error.php,以将404错误重定向到joomla文章.下面的代码适用于404错误,但403返回空白页面.我可以直接导航到我脚本之外的页面,因此它必须是我的代码或它在环境中的交互方式.
谢谢Stephen
defined( '_JEXEC' ) or die( 'Restricted access' );
if ($this->error->code == 404)
{
Header( "HTTP/1.1 404 Not found" );
header("Location: http://www.queensberry.com/misc/filenotfound/");
} else if ($this->error->code == 403) {
Header( "HTTP/1.1 403 Restricted Content" );
Header( "Location: http://www.queensberry.com/restrictedcontent/" );
} else {
echo "hello world error code = " . $this->error->code;
}
?>
Run Code Online (Sandbox Code Playgroud)
我感谢大家的帮助,但答案却让我朝着我希望的方向发展.我想继续使用Joomla的error.php文件作为Joomla错误的目标,但不是格式化页面,看起来它是我想重定向到Joomla内容的网站的一部分.
最后我发现我需要的是出口; 在我的脚本中.所以这里是error.php,因为它现在正在工作.
defined( '_JEXEC' ) or die( 'Restricted access' );
if ($this->error->code == 404)
{
Header( "HTTP/1.1 404 Not found" );
header("Location: http://www.queensberry.com/misc/filenotfound/");
exit;
} else if ($this->error->code == 403) {
Header( "HTTP/1.1 403 Restricted Content" );
Header( "Location: http://www.queensberry.com/restrictedcontent/" );
exit;
} else {
echo "hello world error code = " . $this->error->code;
}
?>
Run Code Online (Sandbox Code Playgroud)