This topic contains a post which is marked as Best Answer. Press here if you would like to see it.
*

bemtele

  • ***
  • 97 posts
Redirect 404 pages to search page
« on: June 22, 2022, 08:07:17 PM »
Please how do I redirect 404 pages to the search page? or any other pages I deemed fit. I have a lot of deleted Ads and I will like to redirect the URL to fix errors in search console. Thank you

*

MB Themes

Re: Redirect 404 pages to search page
« Reply #1 on: June 30, 2022, 10:12:31 AM »
@bemtele
Such fix does not make sense. Those errors are valid I suppose.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

Smithtech

  • ****
  • 219 posts
Re: Redirect 404 pages to search page
« Reply #2 on: July 25, 2022, 09:26:01 PM »
Please, it will be nice to have this option.
Some spammy profiles were deleted for instance and we found out that they created links to their profiles on other websites but their profiles were already deleted so their profile links throws 404 errors.
It will be nice to redirect at least those spammy profile links to other pages on our sites to benefit from those backlinks.

What do you think? :-\

*

bemtele

  • ***
  • 97 posts
Re: Redirect 404 pages to search page
« Reply #3 on: July 25, 2022, 11:29:27 PM »
Please, it will be nice to have this option.
Some spammy profiles were deleted for instance and we found out that they created links to their profiles on other websites but their profiles were already deleted so their profile links throws 404 errors.
It will be nice to redirect at least those spammy profile links to other pages on our sites to benefit from those backlinks.

What do you think? :-\

This is exactly what I want to achieve. People post spam content and after deleting all their contents, I am getting serious errors with the search console. It will be great to redirect such URLs. Popular SEO tools (Such as Yoast) have this option.

*

mwindey

  • *****
  • 478 posts
Re: Redirect 404 pages to search page
« Reply #4 on: July 26, 2022, 10:54:40 AM »
Redirecting error 404 can be solved with a little javascript code adjustment in page 404.php.
Some browsers are not supporting javascript or user disabled it. When that happens a link will be displayed to your search page instead...
Copy and insert before line <div class="error404">
Replace yourdomain with yours:

Code: [Select]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="<?php echo str_replace('_''-'osc_current_user_locale()); ?>">
<head>
  <?php osc_current_web_theme_path('head.php') ; ?>
  <meta name="robots" content="noindex, nofollow" />
  <meta name="googlebot" content="noindex, nofollow" />
  <meta http-equiv="refresh" content="0; url=https://yourdomain/search">
  <script type="text/javascript">
          window.location.href = "https://yourdomain/search"
 </script>
</head>

<body id="p404">
  <?php osc_current_web_theme_path('header.php') ; ?>
 <h1>If you are not redirected automatically, follow this <a href='https://yourdomain/search'>link to visit the website.</a></h1>
  <div class="container">
« Last Edit: July 26, 2022, 03:51:58 PM by mwindey »

Marked as best answer by frosticek on August 01, 2022, 12:03:21 PM
*

mwindey

  • *****
  • 478 posts
Re: Redirect 404 pages to search page
« Reply #5 on: July 26, 2022, 11:06:20 AM »
Because some browser does not support javascript or user disabled it you can also use php in page 404.php
between head tag just put:
Code: [Select]
<?php
    header
("HTTP/1.1 404 REDIRECT");
    
header("Location: https://yourdomain.com/search");
    exit;
?>

« Last Edit: August 01, 2022, 12:03:12 PM by MB Themes »

*

Dan

  • ***
  • 52 posts
Re: Redirect 404 pages to search page
« Reply #6 on: July 26, 2022, 11:24:28 AM »
@mwindey
Thank you for that ,I will also insert in my website

*

bemtele

  • ***
  • 97 posts
Re: Redirect 404 pages to search page
« Reply #7 on: July 27, 2022, 10:18:43 PM »
Because some browser does not support javascript or user disabled it you can also use php in page 404.php
between head tag just put:
Code: [Select]
<?php
    Header
("HTTP/1.1 404 REDIRECT");
    
Header("Location: https://yourdomain.com/search");
?>


Thank you

*

mwindey

  • *****
  • 478 posts
Re: Redirect 404 pages to search page
« Reply #8 on: July 27, 2022, 11:27:28 PM »
Welcome ;)