如何提取的404错误在PHP中的URL参数 [英] How to extract URL parameters on 404 Error in PHP

查看:183
本文介绍了如何提取的404错误在PHP中的URL参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的htaccess重定向到一个error404.php,但我想在PHP文件能够提取原始URL参数。

I have my htaccess redirecting to a error404.php but I want that PHP file to be able to extract the original url parameters.

例如:

http://mywebsite.com/unknownfile.php?param1=value1&param2=value2

我已经试过 $ _ GET ['参数1'] 但这是空的。该 $ _ SERVER ['PHP_SELF'] 只显示error404.php

I've tried $_GET['param1'] but that's empty. The $_SERVER['PHP_SELF'] just shows error404.php

在预先感谢。

推荐答案

您可以通过 $访问原始网址_ SERVER [REQUEST_URI]

例如:请求网址 /日冰/喵键=伦巴不存在。该 $ _ SERVER [REQUEST_URI] 将有一个字符串,你可以用的 parse_url()函数分裂成几部分,并使用其他功能(如爆炸()来获得个人的查询串参数。

For example: requesting URL /hihi/meow?key=rumba which does not exists. The $_SERVER["REQUEST_URI"] will have that string, which you can parse with parse_url() function to split into parts and use other functions (like explode() to get to individual query strung parameters.

这篇关于如何提取的404错误在PHP中的URL参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆