The result is same for all options. Redirect.
<meta>
in HTML:
- Show content of your site, and next redirect user after a few (or 0) seconds.
- Don't need JavaScript enabled.
- Don't need PHP.
window.location
in JS:
- Javascript enabled needed.
- Don't need PHP.
- Show content of your site, and next redirect user after a few (or 0) seconds.
- Redirect can be dependent on any conditions
if (1 === 1) { window.location.href = 'http://example.com'; }
.
header('Location:')
in PHP:
- Don't need JavaScript enabled.
- PHP needed.
- Redirect will be executed first, user never see what is after.
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