// Verbeterde link-herschrijving die ALLE tripforum.nl URLs vangt $response = preg_replace_callback( '/]+href="([^"]+)"/i', function($matches) { $url = $matches[1]; // Behoud sign-up en sign-in redirects naar originele site if (preg_match('/^https:\/\/tripforum\.nl\/forum(sign-up|sign-in)(\/|$)/', $url)) { return $matches[0]; } // Herschrijf ALLE tripforum.nl URLs (inclusief relatieve URLs zonder https) if (preg_match('#^(https?:)?//tripforum\.nl(/.*)?$#i', $url, $match)) { $path = isset($match[2]) ? $match[2] : '/'; $parsed = parse_url($url); $query = isset($parsed['query']) ? '?' . $parsed['query'] : ''; $fragment = isset($parsed['fragment']) ? '#' . $parsed['fragment'] : ''; // Verwijder leading slash en bouw nieuwe URL $cleanPath = ltrim($path, '/'); $newUrl = '/forum/' . $cleanPath . $query . $fragment; // Cleanup dubbele slashes $newUrl = preg_replace('#/+#', '/', $newUrl); return str_replace($matches[1], $newUrl, $matches[0]); } // Ook relatieve URLs die beginnen met / herschrijven if (preg_match('#^/[^/]#', $url)) { $parsed = parse_url($url); $path = $parsed['path'] ?? '/'; $query = isset($parsed['query']) ? '?' . $parsed['query'] : ''; $fragment = isset($parsed['fragment']) ? '#' . $parsed['fragment'] : ''; $newUrl = '/forum' . $path . $query . $fragment; return str_replace($matches[1], $newUrl, $matches[0]); } return $matches[0]; }, $response ); // EXTRA: Herschrijf ook JavaScript variabelen en data-attributes $response = preg_replace_callback( '/(href="|data-[^=]+="|\'|")https?:\/\/tripforum\.nl\//i', function($matches) { $prefix = $matches[1]; // Skip sign-up/sign-in if (preg_match('/forum(sign-up|sign-in)/', $matches[0])) { return $matches[0]; } return $prefix . 'https://triptherapie.nl/forum/'; }, $response ); // Herschrijf ook pagination links in wpForo specifieke attributen $response = str_replace( 'https://tripforum.nl/', 'https://triptherapie.nl/forum/', $response );