Blog Sections Open

Ignoring the q Query Parameter in Ad Landing URLs

A legacy Evolution CMS workaround for ad traffic that appends the reserved q parameter and breaks friendly URLs.

Advertising systems sometimes append a q parameter to landing page URLs. In Evolution CMS that can be a problem because q is historically tied to friendly URL routing. The result is a broken page, a 404 response, or a duplicate URL pattern that search engines should never index.

One practical workaround from the legacy ecosystem was to intercept the request at OnPageNotFound, strip the q parameter, and serve the real resource URL instead.

Legacy plugin pattern

//<?php
/**
 * Q replace
 *
 * Remove $_GET['q'] from url
 *
 * @internal @events OnPageNotFound
 */
if ((strpos($_SERVER['REQUEST_URI'], '&q=') !== false) || (strpos($_SERVER['REQUEST_URI'], '?q=') !== false)) {
    $urls = explode('?', $_SERVER['REQUEST_URI']);
    $gets = [];

    if (!empty($urls[1])) {
        foreach (explode('&', $urls[1]) as $param) {
            $parts = explode('=', $param, 2);
            if (($parts[0] ?? '') !== 'q') {
                $gets[] = $param;
            }
        }
    }

    $url = count($gets) ? $urls[0] . '?' . implode('&', $gets) : $urls[0];
    $content = file_get_contents(MODX_SITE_URL . $url);
    header('HTTP/1.1 200 OK');
    echo $content;
    exit();
}

What this solves

  • broken landing pages caused by ad systems that append q
  • duplicate URL patterns like index.php?q=...
  • SEO noise when campaign traffic hits the wrong routing format

Modern caution

This plugin pattern is useful on legacy projects, but it is still a workaround. If you control your ad URLs, the better fix is to stop sending the reserved parameter in the first place. If you cannot control the traffic source, normalize the URL as early as possible and keep a canonical tag on the final page.

Newer post

Fixing a Parse Error After Installing bLang

A practical troubleshooting checklist for SQL and parser errors that appear after installing bLang on Evolution CMS.

Older post

Replacing Straight Quotes with Typographic Quotes Safely

How to convert straight quotes into typographic quotes without breaking template code, snippets, URLs, or structured content.