<?php
/**
 * 301 redirect: rvrentalstarterkit.com  ->  DigitalExpo Reader for "Your RV Rental Starter Kit"
 *
 * Book ID: book_d8dd5c644794
 * Reader URL: https://www.digitalexpo.ai/?ebook_reader_type=image&ebook_reader_id=1&digitalexpo_book=book_d8dd5c644794
 *
 * Why PHP (not nginx rewrite or .htaccess):
 *   - The stack is nginx; .htaccess does not apply natively.
 *   - eApps / ISPmanager panel regenerates the nginx vhost on any domain config change,
 *     which would clobber an in-vhost rewrite. PHP in the doc root survives that.
 *   - This is a true 301 (SEO-safe), not a meta refresh.
 *
 * UTM tagging: campaign tag is preserved so FB-ad clicks (or any other inbound)
 *   continue to flow attribution to DigitalExpo analytics.
 *
 * Edit history:
 *   2026-05-26  Initial deployment.
 */

$dest_base = 'https://www.digitalexpo.ai/';
$params = [
    'ebook_reader_type'  => 'image',
    'ebook_reader_id'    => 1,
    'digitalexpo_book'   => 'book_d8dd5c644794',
    'utm_source'         => 'rvrentalstarterkit',
    'utm_medium'         => 'redirect',
    'utm_campaign'       => 'kit-domain-301',
];

// Allow inbound ?utm_* to pass through (overrides defaults). Lets FB ads or
// other campaigns set their own utm_source on the way in if they bypass the
// destination link directly.
foreach ($_GET as $k => $v) {
    if (strpos($k, 'utm_') === 0) {
        $params[$k] = $v;
    }
}

$qs = http_build_query($params);
$url = $dest_base . '?' . $qs;

header('HTTP/1.1 301 Moved Permanently');
header('Location: ' . $url);
header('Cache-Control: max-age=86400, public');
header('X-Redirect-Source: rvrentalstarterkit.com');

// Fallback HTML in case the header doesn't take (very rare but cheap insurance).
?>
<!DOCTYPE html>
<html><head>
<meta charset="utf-8">
<title>Your RV Rental Starter Kit</title>
<meta http-equiv="refresh" content="0; url=<?php echo htmlspecialchars($url, ENT_QUOTES); ?>">
<link rel="canonical" href="<?php echo htmlspecialchars($url, ENT_QUOTES); ?>">
</head><body>
<p>Taking you to <a href="<?php echo htmlspecialchars($url, ENT_QUOTES); ?>">Your RV Rental Starter Kit on DigitalExpo</a>&hellip;</p>
</body></html>
