<?php class ProRedirect { /** * Safely redirects to a specific URL. * * @param string $url The target URL. * @param int $statusCode HTTP status code (301, 302, 307, 308). * @param bool $exit Stop script execution immediately. */ public static function to($url, $statusCode = 302, $exit = true) { // 1. Security: Sanitize URL to prevent "Open Redirect" vulnerabilities // We only allow absolute HTTP/HTTPS URLs or relative paths. $url = filter_var($url, FILTER_SANITIZE_URL); // Prevent redirecting to a different domain if you only want internal redirects // Uncomment the next 3 lines to enforce internal-only redirects // $host = parse_url($url, PHP_URL_HOST); // if ($host && $host !== $_SERVER['HTTP_HOST']) { // die("Invalid redirect target."); // } // 2. Validate and Set HTTP Status Code // 301: Moved Permanently (SEO) // 302: Found (Temporary) // 307: Temporary Redirect (Preserves POST data on modern browsers) // 308: Permanent Redirect (Preserves POST data) $validCodes = [301, 302, 303, 307, 308]; if (!in_array($statusCode, $validCodes)) { $statusCode = 302; // Default to 302 if invalid } // 3. Check if headers have already been sent if (headers_sent($file, $line)) { // Fallback: If headers sent, we cannot use header(). Use JS/Meta. // This is critical for plugins/themes that output content early. echo ''; echo ''; if ($exit) die("Redirect failed (Headers already sent in $file on line $line)."); return; } // 4. Execute Native Header Redirect header("Location: " . $url, true, $statusCode); // 5. Optional: Add No-Index headers for temporary redirects if ($statusCode === 302 || $statusCode === 307) { header("X-Robots-Tag: noindex, nofollow", true); } if ($exit) exit; } } // --- USAGE EXAMPLES --- // Example 1: Standard Temporary Redirect ProRedirect::to("https://www.google.com"); // Example 2: SEO Permanent Redirect // ProRedirect::to("https://www.new-site.com", 301); // Example 3: Redirect after form submission (keeps POST data) // ProRedirect::to("/success-page", 307); ?>

A commitment to innovation and sustainability

Études is a pioneering firm that seamlessly merges creativity and functionality to redefine architectural excellence.

Building exterior in Toronto, Canada

A passion for creating spaces

Our comprehensive suite of professional services caters to a diverse clientele, ranging from homeowners to commercial developers.

Renovation and restoration

Experience the fusion of imagination and expertise with Études Architectural Solutions.

Continuous Support

Experience the fusion of imagination and expertise with Études Architectural Solutions.

App Access

Experience the fusion of imagination and expertise with Études Architectural Solutions.

Consulting

Experience the fusion of imagination and expertise with Études Architectural Solutions.

Project Management

Experience the fusion of imagination and expertise with Études Architectural Solutions.

Architectural Solutions

Experience the fusion of imagination and expertise with Études Architectural Solutions.

An array of resources

Our comprehensive suite of professional services caters to a diverse clientele, ranging from homeowners to commercial developers.

Études Architect App

  • Collaborate with fellow architects.
  • Showcase your projects.
  • Experience the world of architecture.
Tourist taking photo of a building
Windows of a building in Nuremberg, Germany

Études Newsletter

  • A world of thought-provoking articles.
  • Case studies that celebrate architecture.
  • Exclusive access to design insights.

“Études has saved us thousands of hours of work and has unlocked insights we never thought possible.”

Annie Steiner

CEO, Greenprint

Watch, Read, Listen

Join 900+ subscribers

Stay in the loop with everything you need to know.