Perfect Page 404

    Good afternoon, dear colleagues. I want to share my best practices with you - the perfect 404 page . This is nothing more than an appended code for an article by Ian Lloyd's “Perfect Page 404” ( original , in Russian ).
    Compared to the original code, the page has the following advantages:
    1. Adapted to the search queries of popular Russian search engines, including now the script can read queries from the search engine entered in Russian letters.
    2. When sending a message about a broken link, the user is not transferred to a new page, but receives thanks on the same page (thanks, Ajax).
    For those who are not familiar with Lloyd's article, I’ll tell you everything from the beginning:
    1. Page 404 of the error does not say that everything is bad. She helps to find the page you need, apologizing along the way.
    2. If you came to the site from one of the popular search engines (yandex, rambler, mail.ru, google, bing.com, nigma), then the page will determine your search query and help the user find that page. For example, your site sells trainers ZP-300 and ZP-800. If the user was looking for the ZP-300 - you can immediately give a link to a page with this simulator. And so for every popular name.
    3. If the user came from a site whose administrator you are, then he will have the opportunity to inform you of a "bad" link with the click of a button.
    4. If the user came from a regular site, then he will be able to inform you of a "bad" link with the click of a button, so that you yourself can solve this problem with the admins of the crookedly linking site.
    Use on health. All places that you need to pay attention to are marked with a comment beginning with "//!".
    I am always open to criticism. I would be grateful if you point out errors in the code, if I suddenly didn’t catch any.
    Update: working example.
    Update2: Fixed the code. Replaced the pure referrer, so as not to fall under XSS
    Update3: In the examples, if you look at the transition from the search engine through IE, your script may write that the user was looking for cracks. This is not a script bug. In real conditions, everything is shown as it should. Just on the page with links IE automatically tries to replace the characters with percentages with their own. To see the result from the search engine in IE, you need to enter the address Update4 with your
    http://baseowl.ru/search.php?q=%D0%BB%D0%B8%D0%B2%D0%B0%D0%BC
    hands:The latest corrections were made at 00:30 Moscow time. Those who downloaded the archive earlier than this time - download it again - you will receive a revised version.

    Also popular now: