-2

Here is Code I used to Redirect

<?php
// 301 Moved Permanently

$id1 = $_SERVER['QUERY_STRING'];
$id2 = $_SERVER['QUERY_STRING'];
header("Location: https://example1.com/away.php?to=https://example2.com/sample-page/?$id1", true, 301);

exit();
?>

When I Pressing The URL

https://example2.com/sample-page/?id1=4567&id2=name

Get The Result

https://example2.com/sample-page/?id1=4567

Not Pressing the URL With Id2=name

Can any one help me to fix this Problem

Want a Result this

https://example2.com/sample-page/?id1=4567&id2=name

  • You want to ignore `id2` ? You can unset it at the beginning of your code. `unset($_GET['id2']);` – Parsa_Gholipour Jan 02 '21 at 16:44
  • I want id2 could be executed after Pressing the url.. Only id1 is Executed after Pressing the url not id2 – Bharat Sharma Jan 02 '21 at 16:49
  • 2
    Does this answer your question? [php - insert a variable in an echo string](https://stackoverflow.com/questions/8054989/php-insert-a-variable-in-an-echo-string) – Remy Jan 02 '21 at 16:56

1 Answers1

0

It simple you didn't use both id to your URL just edit it like this:

header("Location: https://example1.com/away.php?to=https://example2.com/sample-page/?id1={$id1}&id2={$id2}", true, 301);
Milad
  • 328
  • 1
  • 11