Redirect to Home when a page that does not exist in the Wordpress domain is accessed

0

I would like the user to be redirected to the main page of the site when trying to access a non-existent page within the domain.

For example, I have only the following pages:

  • meudominio.com/home
  • meudominio.com/contato

If the user accesses any other page by mistake and / or typos, such as meudominio.com/troll , redirect to meudominio.com/home .

I have read that this is done in the files .htaccess or 404.php , but I do not know how to configure it.

    
asked by anonymous 29.10.2018 / 11:21

3 answers

0

Copy and paste the code below into the 404.php file, and change the text "put url of your site or blog" to your site's home address.

<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: " . get_bloginfo('coloque  o url do seu site ou blog'));
exit();
?>

More details here .

    
29.10.2018 / 12:45
0

Go to your .htacess file and add the following line

ErrorDocument 404 http://meudominio.com/home
    
29.10.2018 / 13:02
0

You can code , as stated in other responses, or use a wordpress plugin .

link

This is an example plugin you can find more that does the same if you look for it.

    
29.10.2018 / 13:20