-7
我需要動態URL這樣的「https://[email protected]」重定向到「https://test.com」我如何重定向動態url與查詢字符串在PHP?
我需要動態URL這樣的「https://[email protected]」重定向到「https://test.com」我如何重定向動態url與查詢字符串在PHP?
如果我理解正確,這個URL與動態查詢字符串的到來。而你想刪除查詢字符串部分並重定向到這個修改後的URL。
我們假設動態URL存儲在變量$ url中。
試試這個:
$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.
可以存儲在一個變量的動態部分,並使用header()
功能來重定向用戶。
$dynamicPart = "[email protected]";
header("Location: https://test.com/index.php?username=".$dynamicPart);
exit;
'<?php header(「location:https://test.com」); ????? – Manikiran
你怎麼得到這個網址?這是在一個變量中排序? –
顯示您的代碼。 – Dave