One page wordpress template – redirect all pages to home

I’ve been searching this for months. Is there a plugin to redirect all pages to home? Or should i just put redirect to page.php template file?

I only have one pager and i need to redirect all pages to home (not posts)

Read More

Thank you

Related posts

Leave a Reply

2 comments

  1. Either your solution, or you can use .htaccess redirect rules, like:

    Redirect /old-index.html http://www.mynewwebsite.com/foldername/new-index.html
    

    or just simple PHP solution, like (you’re able to redirect traffic by putting the following line at the very top of a PHP document, nothing can be above it):

    <?php
       header ('HTTP/1.1 301 Moved Permanently');
       header( "http://www.mynewwebsite.com" );
    ?>
    

    More about .htaccess file redirection here.

    EDIT:

    Place the code below in your .htaccess file.
    This will direct everything from the old host to the root of the new host:

    RewriteEngine on
    RewriteCond %{http_host} ^www.old.com [NC,OR]
    RewriteCond %{http_host} ^old.com [NC]
    RewriteRule ^(.*)$ http://www.new.com/ [R=301,L]
    
  2. I use the following code in functions.php

    function redirect_page_standard() {
      is_page()
        and wp_redirect( home_url(), 301 )
        and exit;
    }
    add_action( 'template_redirect', 'redirect_page_standard' );
    

    You could also redirect just a specific page-template when you replace is_page() with is_page_template('mytemplate.php').