本文介绍了拥有“utm_"在 URL 字符串中破坏了 Wordpress 中的 $_GET 变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先注意:此站点托管在 WPEngine(清漆缓存)上,但我似乎无法在另一台服务器上复制该问题.

First note: This site is hosted on WPEngine (varnish caching), but I can't seem to replicate the issue on another server.

我们需要能够访问某些页面上的 $_GET php 变量.为了测试,我修改了我们的 Wordpress header.php 以在第一行做一个 var_dump.

We need to be able to access the $_GET php variable on some pages. For testing, I modified our Wordpress header.php to do a var_dump on the very first line.

通常,一切正常.但是,如果 URL 字符串包含utm_",则 $_GET 中的每个后续变量都会被剥离.更奇怪的是,如果我登录到 Wordpress,一切正常.

Normally, everything works OK. However if the URL string contains "utm_", every subsequent variable in $_GET is stripped. The extra weird part is that if I am logged in to Wordpress, everything works fine.

我们的 Paypal 返回 URL 如下所示:

Our Paypal return URL looks like this:

http://oururl.com/buy/thankyou/?utm_nooverride=1tx=xxxyyyy...

utm_nooverride 导致 $_GET 为空数组.如果我将其更改为test=1&tx=xxxxyyyy",则它可以正常工作.如果我使用utm_test=1&tx=xxxxyyyy",我会再次得到一个空数组.

The utm_nooverride causes the $_GET to be an empty array. If I change it to "test=1&tx=xxxxyyyy", it works OK. If I use "utm_test=1&tx=xxxxyyyy" I get an empty array again.

.htaccess 中没有什么奇怪的,只有几行标准的 Wordpress 行.

There is nothing odd in the .htaccess, only a few standard Wordpress lines.

主机中是否有什么原因导致了这种情况?

Could there be something in the hosting causing this?

推荐答案

如果其他人遇到同样的问题,就像我刚刚做的那样,我通过实时聊天和 WPEngine 支持团队进行了交谈.他们在几分钟内纠正了它

In case anyone else runs into the same problem, as I just did, I spoke with WPEngine support team via Live chat and. They rectified it within a few minutes

这是我们聊天的简短记录:

Here's a shortened transcript of our chat:

  • 我:我正在尝试将一些 GET 变量放入 cookie 中,当访问 $_SERVER['REQUEST_URI'] 全局变量时,它似乎适用于任意变量(如 my_name=bob),但出于某种原因查询字符串中以utm_"开头的内容被删除.好像是你这边的 php/cache 配置,你知道吗?
  • WPE:好问题;不幸的是,我不知道有什么会自动去除查询中的特定参数.让我和一些同事一起回顾一下.
  • 我:k.仅供参考,这里有一个堆栈溢出问题 http://stackoverflow...-the-get-variable-in-wordpress.其他人的经验似乎也证实了这一点:https://twitter.com/...ey01/status/555584796785528832
  • WPE:这是用于您的安装:?
  • 我:是的
  • WPE:我可以请你现在试试吗?
  • 我:好的,现在可以了.出了什么问题?
  • WPE:太好了!问题是我们默认去掉了utm_"参数.我很抱歉没有意识到您建议的 arg.我不得不从我们的缓存系统中排除这个参数.
  • 我:好的,所以我自己不可能做到这一点,对吗?
  • WPE:没错.
  • Me: I'm trying to put some GET vars into a cookie and it seems like it works for arbitrary variables (like my_name=bob) when accessing the $_SERVER['REQUEST_URI'] global variable, but for some reason anything starting with "utm_" in the query string is being stripped out. Seems to be a php/cache config on your side, do you know anything about this?
  • WPE: Great question; unfortunately, I am not aware of anything automatically stripping out specific args within a query. Let me review this with some colleagues.
  • Me: k. FYI, here's a stack overflow issue http://stackoverflow…-the-get-variable-in-wordpress. seems to be corroborated by others' experience as well: https://twitter.com/…ey01/status/555584796785528832
  • WPE: This is for the your install: ?
  • Me: yes
  • WPE: Can I please have you try now?
  • Me: ok, it works now. what was the issue?
  • WPE: Excellent! The issue was that we strip out the "utm_" arg by default. I apologize for not realizing the arg that you were suggesting. I had to exclude this arg from our caching system.
  • Me: ok, so there's no way I could have done that myself right?
  • WPE: That is correct.

参考链接:https://wpengine.com/support/utm-gclid-variables-caching/

这篇关于拥有“utm_"在 URL 字符串中破坏了 Wordpress 中的 $_GET 变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-22 10:49