From b29647d3f2072d548516e9dbf3b8ff1f8d986d66 Mon Sep 17 00:00:00 2001 From: Jon Goldberg Date: Tue, 11 Apr 2023 16:17:52 -0400 Subject: [PATCH] tell search engines not to index click-through URLs --- CRM/Mailing/Page/Url.php | 1 + CRM/Utils/System.php | 4 +++- extern/url.php | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CRM/Mailing/Page/Url.php b/CRM/Mailing/Page/Url.php index a65ee0d9ec..c924e76f6f 100644 --- a/CRM/Mailing/Page/Url.php +++ b/CRM/Mailing/Page/Url.php @@ -62,6 +62,7 @@ class CRM_Mailing_Page_Url extends CRM_Core_Page { 'for' => 'civicrm/mailing/url', 'queue_id' => $queue_id, 'url_id' => $url_id, + 'noindex' => TRUE, ]); } diff --git a/CRM/Utils/System.php b/CRM/Utils/System.php index 207f6b285a..aed21211d1 100644 --- a/CRM/Utils/System.php +++ b/CRM/Utils/System.php @@ -545,7 +545,9 @@ class CRM_Utils_System { $url = str_replace('&', '&', $url); $context['output'] = $_GET['snippet'] ?? NULL; - + if ($context['noindex'] ?? FALSE) { + self::setHttpHeader('X-Robots-Tag', 'noindex'); + } $parsedUrl = CRM_Utils_Url::parseUrl($url); CRM_Utils_Hook::alterRedirect($parsedUrl, $context); $url = CRM_Utils_Url::unparseUrl($parsedUrl); diff --git a/extern/url.php b/extern/url.php index 27e1c299b7..370a1fe5d2 100644 --- a/extern/url.php +++ b/extern/url.php @@ -54,5 +54,6 @@ if (strlen($query_string) > 0) { $url = str_replace('&', '&', $url); // CRM-17953 - The CMS is not bootstrapped so cannot use CRM_Utils_System::redirect +header('X-Robots-Tag', 'noindex'); header('Location: ' . $url); CRM_Utils_System::civiExit(); -- 2.25.1