I’m trying to use php redirects rather than using javascript to speed up my app. I’ve tried adding the header redirect calls within an action under the init hook since it runs after WordPress has finished loading but before any headers are sent. nothing happens. below is an example:
function redirect()
{
header("Location:http://www.website.com/");
die('should have redirected by now!');
}
add_action('init', 'redirect');
Any thoughts on how I can do php redirects?
thanks
Many times you can do this by signing into your hosted account and just managing DNS from your control panel.
Other wise add this to your index.php file
header(“Location: http://www.example.com“); just above the line that starts with define.
UPDATED:
Review –
https://codex.wordpress.org/Function_Reference/wp_redirect
Thanks !!