php抓取网页匹配url(一个页面不存在,跳转到404,如何把参数也带过去?)
优采云 发布时间: 2022-03-01 10:03php抓取网页匹配url(一个页面不存在,跳转到404,如何把参数也带过去?)
如果某个页面不存在,则跳转到404。如何将参数带到那里?
我今天有个要求:
带参数跳转到不存在的页面会指向404页面,404指向index.php首页,在index.php首页获取get参数。nginx服务器可以获取,Apache服务器获取不到。
案子:
1. 页面不存在
2. 跳转到404页面
3. 此时我想获取index.php中fileName的值
php:
获取上一页url值:
回声 $_SERVER['HTTP_REFERER'];
参考:
爪哇:
获取上一页的值,该值将在 url 中:
String url=request.getHeader("Referer");
获取此页面值:
字符串 url=request.getScheme()+”://”+ request.getServerName()+request.getRequestURI();
====================================================
Apache 404 错误页面配置:
案例:访问一个站点时,如果输入地址错误,会跳转到该站点的首页index.php
假设:如果不存在,跳转到页面
在这两个文件中:
/alidata/server/httpd-2.4.10/conf/httpd.conf
/alidata/server/httpd-2.4.10/conf/extra/httpd-multilang-errordoc.conf
查找
ErrorDocument 404 /404.html
将其更改为:
ErrorDocument 404 /index.php
==================================================== ===
nginx 404错误页面配置:
参考: