我最近升级了一个网站,几乎所有的url都改变了。 我已经把所有这些东西都redirect了(或者我希望如此),但是也有可能它们中的一些已经被我滑倒了。 有没有办法以某种方式捕捉所有无效的URL并将用户发送到某个页面,并以某种方式知道该用户来自哪个URL,这样我就可以logging下来并修复这些? 我想我可以使用.htaccess莫名其妙,但不知道如何。 我正在使用PHP非常感谢!
错误文件已经在.htaccess中,但似乎没有任何改变,你可以看到如下的错误文件
AddHandler application/x-httpd-php5s .php ErrorDocument 404 /content/404.php <IfModule mod_rewrite.c> RewriteEngine on RewriteBase /
看到这个问题我想要的结果是我需要一些东西redirect,如果一些types错误的url只是检查链接,即使你删除一半的位置在结束的URL它仍然打开http://adsbuz.com/classifieds/阿布扎比-UAE /
它sholud去的错误页面,但它不giong我neeed一些有力的力量推到错误页面的感谢
您可以创build一个自定义的404文件。 假设你正在使用Apache,你可以在你的.htaccess中添加下面一行
ErrorDocument 404 /errorfilename.php
此代码基本上告诉服务器,如果用户遇到404(页面未find)错误显示errorfilename.php。
在这个PHP文件中,您可以添加代码,以在用户进入404页面时向您发送电子邮件,或者添加其他支持的逻辑
在PHP中获取404页面的位置,你可以使用下面的全局variables
$_SERVER['HTTP_REFERER']
你的404.php页面的例子
<?php $referer = $_SERVER['HTTP_REFERER']; //this is where you would either email yourself the $referer, //insert it into a database or perform more complex operations. ?> <html> <head> <title>404</title> <body> Sorry, the page you are looking for has been moved/deleted.<br> The system administration has been notified of this error.<br> <a href="index.php">Go to Homepage</a> </body> </html>