Routing: Displaying the Not Found Error
Let's show users a "Page not found" error when they provide a bad URL instead of redirecting them to the homepage.
We'll cover the following...
Creating a new homepage script
When the user provides a bad URL, we should show them a “Page not found” error instead.
The homepage shouldn’t be the default page, it should only show up if we actually go to http://APPLINK/.
First, let’s move the code for the homepage to its own file: public/homepage.php.
We should then update the $urlMap to also include the URL /, which loads the new homepage.php script:
Verify that this works by going to http://APPLINK/.
We should see the homepage, but instead, we get a rather bad error:
Note: Remember, we have used
http://APPLINKjust as a substitute forlocalhost. The URL link on which the application will be available after running the code is located below the ...