Redirect WordPress Permalink

I recently moved this blog from a sub-directory to the root directory. Search engines still show the blog front page as the sub-directory (WordPress delivers post links correctly even though they contain the sub-directory). I needed to redirect old front page links to the new front page. I added a template file to my theme that contained PHP to redirect to the root of the website.

<?php
/*
Template Name: template_redirect
*/
?>
<?php header('Location: https://reubencrane.com');
      die();
?>

Then I added a page named as my old sub-directory and set it’s template to the one above. Try it https://reubencrane.com/blog

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *