如何强制发送无效的url查询到404页面 - PHP

I have custom 404 page and working fine for pages that does not exist.

But I also want to show 404 page if someone query_string found to be missing/invalid/null from url.

How can I do so?

www.example.com/mypage.php?param1=value1
if(isset($_GET['param1']) && $_GET['param1'] !='')
{
   //general code
}
else {
   // Here I want to redirect to 404.php
}

also my 404 page is being accessed directly, and I want to prevent it.

I solved this using include, as Marco Mura suggested in his comment.

www.example.com/mypage.php?param1=value1
if(isset($_GET['param1']) && $_GET['param1'] !='')
{
   //general code
}
else {
   include "404.php";
}

Try to redirect users to 404 page through header() function like this:

www.example.com/mypage.php?param1=value1
if(isset($_GET['param1']) && $_GET['param1'] !='')
{
   //general code
}
else {
   header('Location: http://www.example.com/404.php');
   exit;
}