douyue8191 2014-03-28 14:38
浏览 63
已采纳

显示常规404错误页面

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.)

  • 写回答

1条回答 默认 最新

  • duanbichou4942 2014-03-28 14:42
    关注

    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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口