How to redirect website to error page if query string contains question mark

We can redirect website to error page if url contains query string using htaccess file.

Open .htaccess file and update the following rules.

RewriteEngine on
RewriteCond %{QUERY_STRING} \?
RewriteRule (.*) /404.php? [R,L]

Note that 404.php is the custom error page.

 

Leave a Reply

Your email address will not be published. Required fields are marked *