URL Parameters being stripped when missing the trailing slash

When trying to load a page with a URL parameter like https://www.federaldisability.com/legal-services/federal-disability-retirement?utm_source=Facebook&utm_medium=paid&utm_campaign=campaignname

it gets redirected to the origin page with the URL parameters stripped. Console is showing a 301 redirect.

If we include a trailing slash on the domain before the parameters, then it does not strip the parameters: https://www.federaldisability.com/legal-services/federal-disability-retirement/?utm_source=Facebook&utm_medium=paid&utm_campaign=campaignname

Expected Result
Page loads with full URL + Parameters still intact.

Additional Notes
I’ve studied this KB article (https://developers.cloudflare.com/automatic-platform-optimization/reference/query-parameters/) and the parameters are on that list.

We are using Cloudflare APO with NO Cache or Page Rule.

There are no redirect rules (htaccess or otherwise) that are in place to do this and I have disabled javascript with developer tools to see if some JS was causing the issue but it still happens.

Thoughts on what’s causing this?

First, the redirection is being done by WordPress. Your WordPress permalink structure ends with a slash /, so WordPress does a 301-redirect of the slash-less URL to the canonical URL with the slash… to avoid duplicate content issues.

But this redirection retains the URL variables (query parameters).

I suspect your host WPEngine is stripping out the utm URL variables.

From their support article linked below:

In WP Engine’s cache configuration, we have specific measures in place to ensure that adding URL variables does not cause the page to serve uncached. We call this process “sanitizing”: A request is received by the server and the utm_ or gclid variables are stripped from the end of the URL before sending the request to be generated by PHP. Once the request is compiled, the variables are re-attached to the URL to be returned to the user.

This re-attachment works as long as the original URL requested remains the same. But in this case, where the slash-less URL is being 301-redirected to the canonical URL with a slash (by WordPress), the variables get lost.


This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.