How can one handle outdated QR code links that need to redirect to new pages on a website?
To handle outdated QR code links that need to redirect to new pages on a website, you can create a PHP script that checks the requested URL against a mapping of old URLs to new URLs. If a match is found, the script can then redirect the user to the corresponding new URL.
<?php
// Define mapping of old URLs to new URLs
$redirects = [
'/old-url-1' => '/new-url-1',
'/old-url-2' => '/new-url-2',
'/old-url-3' => '/new-url-3',
];
// Get the requested URL
$requestUrl = $_SERVER['REQUEST_URI'];
// Check if the requested URL matches any of the old URLs
if (array_key_exists($requestUrl, $redirects)) {
// Redirect to the corresponding new URL
header('Location: ' . $redirects[$requestUrl]);
exit;
}
// If no match is found, continue serving the requested page
// Add your regular website logic here
?>
Related questions
-
PHP optimization PLESK integration performance tuning
-
PHP compiling mail()
-
WordPress shortcode toggle