## url rewriting – Page get parameter doesn’t work with is_single() function

Question

If exist the page parameter in the blog post, I have to redirect to the 404 page instead of current post URL.
I tried to check the current page type (is singular) and try to get page parameter in the function.php, but I couldn’t. It’s doesn’t work together. I need to implement it only for blog post.
If possible .htaccess redirect also fine

I tried with this code but it doesn’t work. But it’s working without the is_single function. When I used is_single functions, the page parameter not returning.

It’s not working

add_action('send_headers', 'post_page_param_404_redirect');
function post_page_param_404_redirect() {
global $wp_query; if (is_single() && isset($_GET['page'])) {
$wp_query->set_404(); status_header(404); get_template_part(404); exit(); } }  When I don’t use the is_single function , It’s working for all page, but I need it only for the blog post add_action('send_headers', 'post_page_param_404_redirect'); function post_page_param_404_redirect() { global$wp_query;
if (isset($_GET['page'])) {$wp_query->set_404();