且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在PHP中删除查询字符串(有时基于引荐来源网址)

更新时间:2023-11-15 12:39:16

PHP中最简单的方法:

Easiest way in PHP:

$url = preg_replace('/\?.*/', '', $url);

Facebook所做的可能就是这种方式的JavaScript:

What Facebook does is probably a JavaScript thing, in that fashion:

if (location.href.match(/\?.*/) && document.referrer) {
   location.href = location.href.replace(/\?.*/, '');
}