doucheng9634 2013-02-01 18:07
浏览 289
已采纳

如何获取Not Found页面的URL,以便在自定义404页面中显示它?

Ok, I have a issue with my Webserver, when I try using

<?php echo "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" ?>

It turns up the file it's self: Eg. blah.com/404.php

Also how would I do this with a 403 page? I know its possible and I've tried

    $_SERVER['HTTP_REFERER']

but noting turns up, or sometimes it's just a zero. This is my first time with a 404, what am I doing wrong?

  • 写回答

2条回答 默认 最新

  • douhuan2101 2013-03-06 23:49
    关注

    I found the Issue, You must post a relative path, not a direct link, otherwise it will redirect to that page instead of showing the 404.

    Eg:

     ErrorDocument 404 /404.php
    

    That way the .htacess doesn't redirect to Yoursite.com/notfound.php It will also send a 404 (Not Found) instead of a 200 (OK)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100