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 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥15 关于超局变量获取查询的问题
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集
  • ¥15 在启动roslaunch时出现如下问题
  • ¥15 汇编语言实现加减法计算器的功能
  • ¥20 关于多单片机模块化的一些问题