Contents
Why do I have a 404 error page in PHP?
I’m going to ignore the whole “let’s follow standards” thing I usually do. The reason I chose PHP for the error page is because you can figure out the source of the error to an extent; you can see if the missing page was typed in the address bar, if it was a link on your site, or if it was a link on a different site.
What to do when you get a 404 page on your website?
Now try to visit a non-existent page. You should see your 404 page. Add a few dead links on your site and try to follow them. You should end up with the same 404 page but with different content. Add a dead link to another website and the 404 page will have different content.
What to do with custom error page in PHP?
As stated on the cover page, your custom error page (s) can have any extension you want. But you can’t use it if your server isn’t told to use it. This is where .htaccess comes in. .htaccess is a file named, well, “.htaccess”. This file can be used to configure your site to certain degrees.
Can a PHP error page be written in shtml?
Your error pages may be of any extension you want. Usually, they are written in SHTML. But SHTML isn’t very dynamic in terms of what can be done with it. So I went over to PHP for my error pages. The coding wasn’t hard either. So let’s begin. If you have a website, your hosing server should have PHP installed.
How can I change the content of a 404 page?
You should see your 404 page. Add a few dead links on your site and try to follow them. You should end up with the same 404 page but with different content. Add a dead link to another website and the 404 page will have different content. Here are the files used in this ible. Edit as desired/required.
What happens when you get a 404 code?
What you’re doing will work, and the browser will receive a 404 code. What it won’t do is display the “not found” page that you might be expecting, e.g.:
Why is PHP not found on this server?
What it won’t do is display the “not found” page that you might be expecting, e.g.: The requested URL /test.php was not found on this server. That’s because the web server doesn’t send that page when PHP returns a 404 code (at least Apache doesn’t).
What to do if custom 404 page does not work?
Reloading the page should give a 500 error. If not, make sure your site is set up to use .htaccess files (I just had to edit my server’s config files to get it to work). If it still don’t work, try deleting all the blank spaces and reinserting them.
Is it good to redirect to 404 page?
It’s not good to REDIRECT to your 404 page, but you can INCLUDE the content from it with no problem. That way, you have a page that properly sends a 404 status from the correct URL, but it also has your “what are you looking for?”