'; } /** * Get URL for a specific page by key * * @param string $pageKey The page identifier * @return string The full canonical URL */ function getPageUrl($pageKey) { $baseUrl = 'https://ukaiautomation.co.uk'; $urls = [ 'home' => '', 'about' => '/about', 'quote' => '/quote', 'faq' => '/faq', 'blog' => '/blog', 'contact' => '/#contact', 'privacy' => '/privacy-policy', 'terms' => '/terms-of-service', 'cookies' => '/cookie-policy', 'gdpr' => '/gdpr-compliance', 'project-types' => '/project-types', 'case-studies' => '/case-studies', // Services 'services' => '/#services', 'competitive-intelligence' => '/services/competitive-intelligence', 'price-monitoring' => '/services/price-monitoring', 'data-cleaning' => '/services/data-cleaning', 'data-analytics' => '/services/data-analysis-services', 'api-development' => '/services/api-development', 'property-data' => '/services/property-data-extraction', 'financial-data' => '/services/financial-data-services', // Locations 'london' => '/locations/london', 'manchester' => '/locations/manchester', 'birmingham' => '/locations/birmingham', 'edinburgh' => '/locations/edinburgh', 'cardiff' => '/locations/cardiff' ]; $path = $urls[$pageKey] ?? ''; return $baseUrl . $path; } /** * Check if current page is the canonical version * * @return bool True if current URL is canonical */ function isCanonicalUrl() { $currentUrl = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $canonical = getCanonicalUrl(); return cleanCanonicalUrl('https://ukaiautomation.co.uk', $currentUrl) === $canonical; } /** * Output redirect to canonical URL if needed * Call this at the very beginning of pages before any output */ function enforceCanonicalUrl() { if (!isCanonicalUrl()) { $canonical = getCanonicalUrl(); header('HTTP/1.1 301 Moved Permanently'); header('Location: ' . $canonical); exit; } }