2

I am trying to redirect to url

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

But when I try this one it redirect to me this url http://icommand//?username=Sachin. The colon does not come after icommand. I have tried but doesn't get solution.

2 Answers2

1

This will work:

<?php
     $url = "//icommand://?username=Sachin";
     header("Location: ".$url."");
?>
S.I.
  • 3,250
  • 12
  • 48
  • 77
Daljeet Singh
  • 704
  • 3
  • 7
  • 17
1

try this: urlencode();

$url = "//icommand://?username=Sachin";
header("Location: ".urlencode($url)."");
Amit Kumar Sahu
  • 495
  • 6
  • 15
  • It's wrong. It is redirecting to http://localhost/test/%2F%2Ficommand%3A%2F%2F%3Fusername%3DSachin – Sachin Sharma Nov 04 '16 at 06:38
  • this url is "url encoded" all the special symbol are encoded when you decode the url you will get the same "//icommand://?username=Sachin" refer http://php.net/manual/en/function.urlencode.php – Amit Kumar Sahu Nov 04 '16 at 07:56