user2469520
user2469520

Reputation:

Display General 404 Error Page

If I have a static page at World/index.php that displays pages where the URL's match database values (e.g. MySite/World/New_York), I can write a query that fetches a 404 error page when visitors type in incorrect URL's (e.g. New_Yorc).

But if someone misspells the section name - e.g. MySite/Wurld - they're completely out of the loop. In Chrome, I get a generic error:

Not Found The requested URL /Wurld/ was not found on this server.

How can I create an error page that will display sitewide in every instance where my regular 404 pages don't display?

(I'm working with PHP and MySQL.)

Upvotes: 0

Views: 74

Answers (1)

Nick Zulu
Nick Zulu

Reputation: 331

Simply create an 404.php file with your error message and add this line to your .htaccess file located on the root of your server

ErrorDocument 404 /404.php

all "page not found" pages will be automatically redirected to 404.php

Upvotes: 1

Related Questions