Home  >  Article  >  Backend Development  >  404 - header('http/1.1 404 not found'); Why not jump? (PHP)

404 - header('http/1.1 404 not found'); Why not jump? (PHP)

WBOY
WBOYOriginal
2016-08-04 09:20:052007browse

As far as I know, add the following sentence to the .htaccess or apache config file:
ErrorDocument 404 /missing.html (Note: I have created this file)
Then, when we enter a url that does not exist, This missing.html page will appear.
Then I tried it again and wrote the following code in test.php:

<code><?php
header('HTTP/1.1 404 Not Found');
?>
</code>

Found that the missing.html page will not be displayed.
Then I want to ask, how to display it?
Or maybe I am wrong in writing this? Why?
In fact, what is the use of header('HTTP/1.1 404 Not Found');?

New to PHP, I hope you guys can give me some advice, thank you!

Reply content:

As far as I know, add the following sentence to the .htaccess or apache config file:
ErrorDocument 404 /missing.html (Note: I have created this file)
Then, when we enter a url that does not exist, This missing.html page will appear.
Then I tried it again and wrote the following code in test.php:

<code><?php
header('HTTP/1.1 404 Not Found');
?>
</code>

Found that the missing.html page will not be displayed.
Then I want to ask, how to display it?
Or maybe I am wrong in writing this? Why?
In fact, what is the use of header('HTTP/1.1 404 Not Found');?

New to PHP, I hope you guys can give me some advice, thank you!

HTTP status code: http://baike.sogou.com/v78674...


The ErrorDocument in the Apache configuration uses a page to display the corresponding error status information, not a jump. Please use 302,301 or JS, HTML meta refresh for jump

web server configuration

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn