Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>First of all you need to get complete URL, for example for my local server: </p> <pre class="lang-none prettyprint-override"><code>http://localhost/server_var.php?foo=bar&amp;second=something </code></pre> <p>Try printing <code>$_SERVER</code> variable with <code>print_r()</code>:</p> <pre class="lang-php prettyprint-override"><code>print_r( $_SERVER); </code></pre> <p>You should get result like this:</p> <pre class="lang-none prettyprint-override"><code>Array ( ... [REQUEST_URI] =&gt; /server_var.php?foo=bar&amp;second=something ... ) </code></pre> <p>For more info take a look at <a href="http://php.net/reserved.variables.server.php" rel="nofollow">manual page</a>, so now you have your URL:</p> <pre class="lang-php prettyprint-override"><code>$url = 'http://www.mySecondSite.com' . $_SERVER['REQUEST_URI']; </code></pre> <p>And you can use <a href="http://php.net/manual/en/function.header.php" rel="nofollow"><code>header()</code></a> to redirect your request:</p> <pre class="lang-php prettyprint-override"><code>header( 'Location: ' . $url); </code></pre> <p>I recommend taking look at <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html" rel="nofollow">HTTP status codes</a>, <code>3xx</code> ones, whether you want to use <code>302 Found</code> (the default) or <code>307 Temporary Redirect</code>...</p> <blockquote> <p>The second special case is the "Location:" header. Not only does it send this header back to the browser, but it also returns a REDIRECT (302) status code to the browser unless the 201 or a 3xx status code has already been set.</p> </blockquote> <p>So you can do this:</p> <pre class="lang-php prettyprint-override"><code>header('HTTP/1.0 307 Temporary Redirect'); header( 'Location: ' . $url); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload