GSC: Not found(404) and Page with redirect - page ending with /1000

42 views Asked by At

(I have my website setup in Wordpress) In Google Search Console Page> Page indexing > Not found (404) and >Pages with redirect, around 50% of the pages of my website are ending with /1000

As per Google Support Forum reply, these pages should be made 404 redirect. And everywhere I searched, they are suggesting to add a use case basis code for urls ending with "/1000" to redirect to 404. As Wordpress itself detects the non-existent pages and makes them 404.

I set up a custom redirection for pages ending with "/1000" I used the below code, but the url is changing to our template ID: /?<template_ID>

 // Check if the requested URL ends with "/1000"
    $request_uri = $_SERVER['REQUEST_URI'];
    $url_ending = '/1000';
    
    if (substr($request_uri, -strlen($url_ending)) === $url_ending) {
    // Set the 404 status code
    status_header(404);
        
        $custom_template_permalink = get_permalink(155332);

        // Display the custom Oxygen template content
        wp_redirect($custom_template_permalink);
        exit();
    }
}
add_action('parse_request', 'intercept_urls_ending_with_1000');

After implemetning this, the page is redirecting to my custom 404 page but the link is coming as

example404page.com/?p=15532

I want to redirect all pages ending with “/1000” to 404 status code and show our custom Oxygen builder designed 404 template.

Any ideas how i can achieve this without having the ?p=15523 or something come up at last

0

There are 0 answers