PHP无法重定向到包含冒号的url

时间:2016-11-03 13:02:20

标签: php

我正在尝试重定向到网址

<?php
$url = "https://icommand://?username=Sachin";
header("Location: ".$url."");
?>

但是当我尝试这个时,它会重定向到我这个网址 http://icommand//?username=Sachin。 icommand后结肠不会来。 我已经尝试但没有得到解决方案。

2 个答案:

答案 0 :(得分:1)

这将有效:

<?php
     $url = "//icommand://?username=Sachin";
     header("Location: ".$url."");
?>

答案 1 :(得分:1)

试试这个:urlencode();

$url = "//icommand://?username=Sachin";
header("Location: ".urlencode($url)."");
相关问题