Ошибка означает, что исходный файл w_powf.c недоступен в вашей системе. По-видимому, это не связано с вашей программой. Вы можете смело игнорировать эту ошибку.
Обратите внимание, что в строках, которые вы упомянули, есть оператор **
, который, я полагаю, реализован в этом файле, поэтому он просто говорит вам, что нет доступа к исходному коду реализация этого оператора.
show_404 ()
на самом деле отправляет правильные заголовки для поисковой системы, чтобы зарегистрировать ее как страницу 404 (она отправляет статус 404).
Используйте надстройку Firefox для проверки заголовков, полученных при вызове show_404 ()
. Вы увидите, что он отправляет правильный код состояния HTTP.
Проверьте значение по умолчанию application / errors / error_404.php
. Первая строка:
<?php header("HTTP/1.1 404 Not Found"); ?>
Эта строка устанавливает статус HTTP как 404. Это все, что вам нужно, чтобы поисковая система считала вашу страницу как страницу 404.
Если вам нужна пользовательская страница с ошибкой, вы можете сделать следующее: в ваших библиотеках создайте имя файла MY_Exceptions и расширьте его с помощью CI_Exceptions . Затем переопределите функцию show_404 () ]. В этой функции теперь вы можете создать экземпляр вашего класса Controller с помощью функции & amp_ get_instance (). И с помощью этого экземпляра вы можете загрузить свою пользовательскую страницу 404 Error.
class MY_Exceptions extends CI_Exceptions {
public function __construct(){
parent::__construct();
}
function show_404($page = ''){ // error page logic
header("HTTP/1.1 404 Not Found");
$heading = "404 Page Not Found";
$message = "The page you requested was not found ";
$CI =& get_instance();
$CI->load->view('/*Name of you custom 404 error page.*/');
}
Только следующие шаги:
Шаг 1 Обновите файл application / config / rout.php
$route['404_override'] = 'error/error_404';
Шаг 2 Создать ваш собственный контроллер в папке контроллеров ex. error.php
<?php
class Error extends CI_Controller
{
function error_404()
{
$data["heading"] = "404 Page Not Found";
$data["message"] = "The page you requested was not found ";
$this->load->view('error',$data);
}
}
?>
Шаг 3 Создайте свой вид в папке представлений ex. error.php
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
<title><?php echo $heading;?></title>
</head>
<body>
<?php echo $message;?>
</body>
</html>
попробуйте использовать это
set_status_header(404);
Создайте контроллер в папке приложения / контроллеров.
class Error extends Controller
{
function error_404()
{
$this->load->view('error');
}
}
Затем в вашем приложении / библиотеке расширьте класс Router, создав application / library / MY_Router.php
class MY_Router extends CI_Router
{
private $error_controller = 'error';
private $error_method_404 = 'error_404';
function MY_Router()
{
parent::CI_Router();
}
// this is just the same method as in Router.php, with show_404() replaced by $this->error_404();
function _validate_request($segments)
{
// Does the requested controller exist in the root folder?
if(file_exists(APPPATH.'controllers/'.$segments[0].EXT))
{
return $segments;
}
// Is the controller in a sub-folder?
if(is_dir(APPPATH.'controllers/'.$segments[0]))
{
// Set the directory and remove it from the segment array
$this->set_directory($segments[0]);
$segments = array_slice($segments, 1);
if(count($segments) > 0)
{
// Does the requested controller exist in the sub-folder?
if(!file_exists(APPPATH.'controllers/'.$this->fetch_directory().$segments[0].EXT))
{
return $this->error_404();
}
}
else
{
$this->set_class($this->default_controller);
$this->set_method('index');
// Does the default controller exist in the sub-folder?
if(!file_exists(APPPATH.'controllers/'.$this->fetch_directory().$this->default_controller.EXT))
{
$this->directory = '';
return array();
}
}
return $segments;
}
// Can't find the requested controller...
return $this->error_404();
}
function error_404()
{
$segments = array();
$segments[] = $this->error_controller;
$segments[] = $this->error_method_404;
return $segments;
}
function fetch_class()
{
// if method doesn't exist in class, change
// class to error and method to error_404
$this->check_method();
return $this->class;
}
function check_method()
{
$class = $this->class;
if (class_exists($class))
{
if ($class == 'doc')
{
return;
}
if (! in_array('_remap', array_map('strtolower', get_class_methods($class)))
&& ! in_array(strtolower($this->method), array_map('strtolower', get_class_methods($class))))
{
$this->class = $this->error_controller;
$this->method = $this->error_method_404;
include(APPPATH.'controllers/'.$this->fetch_directory().$this->error_controller.EXT);
}
}
}
}
Если страница не существует, она будет быть направленным на контроллер ошибок