重定向到PHP中的另一个URL [关闭]

I want to Redirect to a website xxx.com from yyy.com

I have this HTML code

<html>

<head>

<title>Redirect Page</title>

</head>

<body>

<form action="" method="get">

<input type="text" name="site" value="">

<input type="submit" value="Redirect" id="form_submit"/>

</form>

</body>

</html>

I want to be redirected to the site, I post in the input value.

Once you have submitted your form, you will neded to detect the form submission and redirect using header() before any HTML output. Place this at the top of your page (presuming that you are in a php file) before your opening <html>:

<?php
if ((isset($_GET['site'])) && ($_GET['site'] != '')){

    header("Location: ".$_GET['site']);
    exit;
}
?>

Try something like this?

<?php
// Make sure this is the first thing on the page you're posting on.
if isset($_GET['site'])
header('Location: '.$_GET['site']);

?>
$url = $_POST['url'];
header("Location: $url");
die();

You can try this below code

<?php

if (!filter_var($_REQUEST['site'], FILTER_VALIDATE_URL) === false) {
  header('Location: ' . $_REQUEST['site'], TRUE, 302);
}