简体   繁体   English

如何从一个链接重定向到另一个?

[英]How to redirect from a link to another?

如果我在这个链接website.com/index.php?id=19我希望如果你尝试删除?id=..所以链接只是website.com/index.php用户将被重定向到website.com/index.php?id=..我该怎么做?

Use header and $_GET - for example:使用header$_GET - 例如:

if (!isset($_GET['id']) || empty($_GET['id'])) {
   header('Location: /index.php?id=155');
   exit();
}

Where 155 is whatever you want there to be. 155是您想要的任何地方。

You can try like this你可以这样试试

if(!isset($_GET['id']))
{
   header('location:index.php?id=here is your id value');
   exit;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM