-7

I need to redirect dynamic URL like this "https://[email protected]" to "https://test.com"

2 Answers2

0

If I understand correctly, this URL is coming dynamically with a query string. And you want to remove the query string portion and redirect to this modified URL.

Let's assume the dynamic URL is stored in a variable $url.

Try this:

$url = "https://[email protected]";
$modified_url = strstr($url, "?", true); // Remove the query string, which results in https://test.com

header("location:".$modified_url);  // Redirect to the modified URL.
Indrasis Datta
  • 8,692
  • 2
  • 14
  • 32
0

You can store the dynamic part in a variable and use the header() function to redirect your user.

$dynamicPart = "[email protected]";
header("Location: https://test.com/index.php?username=".$dynamicPart);
exit;
Peter
  • 8,776
  • 6
  • 62
  • 95