using JS : (in <head>
tag)
<script>window.location="https://stackoverflow.com";</script>
using PHP : (in <head>
tag)
header('Location: https://stackoverflow.com');
end();
Which one I should use ? or another ?
and what about using <meta>
?
<meta http-equiv="refresh" content="0;url=https://stackoverflow.com"/>
Many good answers , I don't know which answer I will accept, Thanks so much
The result is same for all options. Redirect.
<meta>
in HTML:
window.location
in JS:
if (1 === 1) { window.location.href = 'http://example.com'; }
.header('Location:')
in PHP:
header()
must be the first command in php script, before output any other. If you try output some before header, will receive an Warning: Cannot modify header information - headers already sent