【问题标题】:Page not redirecting when given specific url给定特定网址时页面不重定向
【发布时间】:2016-03-25 12:26:17
【问题描述】:

我在操作后重定向页面时遇到了这个奇怪的问题。 仅当我想重定向到特定页面时才会发生这种情况。 我得到这样的当前网址

$actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";

然后将其发送到我的操作文件中,如下所示:

lib/actions.php?module=shopping_cart&action=remove_item&removable_id=<?php echo $product_id;?>&current_url=<?php echo $actual_link;?>

当在动作文件中收到时,我会像这样重定向:

Header("Location:$current_url");

它适用于 url 之类的:

http://localhost/restaurant/index.php?module=booking

http://localhost/restaurant/index.php?module=booking

但是当涉及到这个网址时:

http://localhost/restaurant/index.php?module=booking&action=dishes_selection

什么都没发生 即使我尝试回显 $current_url 它什么也没显示... 真令人沮丧:( 有人可以帮帮我吗 ??

【问题讨论】:

标签: php url redirect


【解决方案1】:

而不是 header("location") 使用 redirectTo('link') ,使用 php 函数的 javascript 重定向

function redirectTo($url)
{
     echo "<script>";
     echo "window.location.href='<?=$url?>'";
     echo "</script>";

}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-04-17
    • 1970-01-01
    • 2012-06-02
    • 1970-01-01
    • 2023-03-12
    • 2016-10-18
    • 2018-02-11
    相关资源
    最近更新 更多