Roots 7.0.1 - PHP Header Location Not Working

I’ve done the 7.0.1 update Roots project. And all PHP Header Location not working.
For Roots 6.5.2 is fully working.

An example: I redirect all 404 on the homepage but it does not work.

My code:

// 301 Moved Permanently
<?php get_template_part('templates/page', 'header'); ?>

<div class="alert alert-warning">
  <?php _e('Sorry, but the page you were trying to view does not exist.', 'roots'); ?>

<p><?php _e('It looks like this was the result of either:', 'roots'); ?></p>
  <li><?php _e('a mistyped address', 'roots'); ?></li>
  <li><?php _e('an out-of-date link', 'roots'); ?></li>

<?php get_search_form(); ?>

Please check and showed me how to perform the function Header Location with Roots.


This probably is not related to Roots. Besides, if you want to redirect all 404s to your homepage you’re probably better off using template_redirect.

1 Like

tmducqt - What is the relative file path from the roots root directory and file-name you are displaying at the top of this thread? My guess is this ‘404’ template is getting loaded after another template and the headers cannot be redefined. I’d look into following the advice of the previous poster.

1 Like