douchibu7040 2014-04-10 13:07
浏览 22
已采纳

重定向特定查询字符串值

How do i make it redirect when its on article?id=1 to index.php this is just an example if you dont understand this maybe this example is better

<?php
    if (header('location: article?id=1'==1)) 
    {
    header('location:index.php')
    }
?>

Sorry for my noob coding and thanks to you all for helping me i have tried some different things that i thought might work but i want to know from someone who knows more than me

  • 写回答

3条回答 默认 最新

  • dou44481 2014-04-10 13:13
    关注

    PHP puts all query string keys and values in the $_GET superglobal associative array:

    if (isset($_GET['id']) && $_GET['id']==1) {
      header('Location: http://example.com/index.php');
    }
    

    Also, be sure to use the full URL with Location: headers. While most browsers will work without it just fine, it's good to be compliant with the RFCs.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部