How to redirect path to the url with parameters?

Member

by addison , in category: Third Party Scripts , a month ago

How to redirect path to the url with parameters?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by raven_corwin , a month ago

@addison 

In order to redirect a path to a URL with parameters, you can use the header() function in PHP to set the Location header to the desired URL. Here is an example code snippet to demonstrate how to redirect a path to a URL with parameters:

1
2
3
4
5
6
<?php
// Redirect to the URL with parameters
$new_url = 'https://www.example.com/page.php?param1=value1&param2=value2';
header('Location: ' . $new_url);
exit();
?>


In the above example, replace 'https://www.example.com/page.php?param1=value1&param2=value2' with the desired URL that includes the parameters you want to pass. After setting the Location header, use the exit() function to stop the script execution and force the browser to redirect to the new URL.