I need to redirect dynamic URL like this "https://test.com?user=abc@gmail.com" to "https://test.com"
Asked
Active
Viewed 342 times
-7
-
`` ??? – Manikiran Aug 22 '16 at 06:36
-
And how are you getting this url? Is this storted in a variable? – Indrasis Datta Aug 22 '16 at 06:37
-
But I think you need user query string in the next page on same URL. right ? If yes then you just need to post the variable with corresponding value. – PHP Geek Aug 22 '16 at 06:38
-
I am getting abc@gmail.com using session from database i make a query string https://test.com?user=abc@gmail.com when i reffer this to https://test.com?user=abc@gmail.com any of new user when new user enter this url on browser side it shoud redirect to https://test.com. – Dushyant Sharma Aug 22 '16 at 07:11
2 Answers
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://test.com?user=abc@gmail.com";
$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 = "someguy@somedomain.com";
header("Location: https://test.com/index.php?username=".$dynamicPart);
exit;

Peter
- 8,776
- 6
- 62
- 95