You can’t match the query string using a mod_alias RedirectMatch
directive. This directive matches against the URL-path only. You need to use mod_rewrite instead, with a condition that checks the QUERY_STRING
server variable.
For example, at the top of your .htaccess
file, try the following:
RewriteCond %{QUERY_STRING} ^page_id=\d+$
RewriteRule ^$ / [QSD,R=302,L]
The QSD
flag (Apache 2.4) is required to remove the query string from the target URL.
However, from an SEO perspective, mass redirections like this will likely be seen as soft-404s by the search engines. You should try to redirect on a per page basis to the new URL. If the content no longer exists then return a 404.