How redirect without header in php?

by ervin.williamson , in category: SEO Tools , 6 months ago

How redirect without header in php?

Facebook Twitter LinkedIn Telegram Whatsapp Pocket

1 answer

by harrison.goodwin , 6 months ago

@ervin.williamson 

In PHP, you can redirect without headers by using the meta tag in HTML.


Here is an example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
<?php
$url = 'https://www.example.com'; // URL to redirect

echo '<html>';
echo '<head>';
echo '<meta http-equiv="refresh" content="0;url=' . $url . '">';
echo '</head>';
echo '<body>';
echo '<p>Redirecting to ' . $url . '.</p>';
echo '</body>';
echo '</html>';
?>


In the above example, the meta tag is used to specify the redirection. The content attribute specifies the time delay in seconds (0 in this case) before redirecting to the specified URL.


The text "Redirecting to URL" can be customized to display any message before redirecting.


Please note that this method does not rely on the HTTP headers for redirection.