If your webpage shows 301 or 404, it is a very serious problem for the user experience, so we must be careful when doing php header301 or 404, let me take a look.
301 jump
| The Code is as follows: |
Copy code |
Header ('HTTP/1.1 301 Moved Permanently '); Header ('location: http://www.abc.com/aaa /'); Exit (); |
Do not miss the header ('HTTP/1.1 301 Moved Permanently '); otherwise, no 301 is returned.
404 error page
| The Code is as follows: |
Copy code |
Header ("HTTP/1.1 404 Not Found "); |
If the above does not work, try the following:
| The Code is as follows: |
Copy code |
Header ("Status: 404 Not Found "); |
So to be foolproof, you can write either of the following two sentences:
| The Code is as follows: |
Copy code |
Header ("HTTP/1.1 404 Not Found "); Header ("Status: 404 Not Found "); |
TIPS,
After writing the code, we must use the webmaster tool to test whether the returned status is what we want.