php url无效,php – 捕获所有无效的URL

论坛 期权论坛 编程之家     
选择匿名的用户   2021-5-23 12:43   25   0

您可以使用用PHP编写的自定义

ErrorDocument处理程序来捕获“滑过”的URL:

# .htaccess file

ErrorDocument 404 /not-found.php

在not-found.php中:

switch($_SERVER['REDIRECT_URL']) {

case '/really_old_page.php':

header('HTTP/1.1 301 Moved Permanently');

header('Location: /new-url/...');

/* As suggested in the comment, exit here.

Additional output might not be handled well and

provokes undefined behavior. */

exit;

default:

header('HTTP/1.1 404 Not Found');

die('404 - Not Found');

}

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP