Restrict Access To index.php - Apache

You can do something like the following using mod_rewrite, near the top of your root .htaccess file:

RewriteEngine On
RewriteCond %{QUERY_STRING} ^param1=value1$
RewriteRule ^(index\.php)?$ - [F]

This will return a 403 Forbidden if either of the following URLs are requested:

  • /?param1=value1
  • /index.php?param1=value1

Note that this matches the query string (URL parameters) exactly as stated in your example. Anything else will be permitted.

UPDATE

how would I deny access if any parameters exist?

In this case, you can change the condition to simply match anything. That is something, but not nothing. For example:

RewriteCond %{QUERY_STRING} .

The dot (.) matches any character.