【问题标题】:Redirect all visitors based on url parameter根据 url 参数重定向所有访问者
【发布时间】:2019-04-20 13:24:21
【问题描述】:

我想根据url中的参数重定向用户吗?

https://example.com/redirect_handler?param=foo&url=http//currentuserwebsite.com

https://example.com/redirect_handler?param=foo&url= 因此用户将首先被重定向到 exmple.com,然后根据 url 参数,用户将被重定向到 url 参数(到用户管理员)。

有可能吗?

【问题讨论】:

  • 是的,您可以这样做。您从 URL 中读取参数,然后在重定向中使用它。
  • @DirkJ.Faber 可以给我看一个简单的例子吗,我是新手..请..我必须使用 $_GET('url') 吗?但如何知道用户何时点击我的页面
  • 类似 <?php echo $_GET['url']; 的东西来回显 URL 参数。将其用于重定向。
  • @DirkJ.Faber 好的,谢谢。让我试试

标签: php wordpress redirect dns


【解决方案1】:

这是您应该尝试的示例:

所以假设链接是 https://example.com/redirect_handler?param=foo&url=http//currentuserwebsite.com

您需要做的是: 在 php 文件的顶部写下以下代码:

<?php 
if(isset($_GET['url'])){ //check if the URL parameter is there
$url = $_GET['url']; //declare $url as the parm 
Header('Location:'.$url); //note if you are using WordPress use wp_redirect Function
} //end if
?>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-01
    • 2018-07-06
    • 2013-01-13
    • 2015-01-16
    • 2016-03-10
    相关资源
    最近更新 更多