-1

i want to set 404 to all url with parameter (?), now its give 200 status code. How can I do it? Example url with parameters:

https://www.google.com/?pomg

https://www.google.com/product/?spingoms

?spingoms , ?pomg - parameters

I want something like this - /?(.*) - [R=404,NC,L] But everything i tried didn't work. thanks

asilv733
  • 19
  • 2
  • Does this answer your question? [Rewrite for an empty query string](https://stackoverflow.com/questions/3630853/rewrite-for-an-empty-query-string) (it does the opposite, but all you need to do is negate the condition.) – CBroe Jun 22 '23 at 10:33

1 Answers1

1

This one works:

RewriteCond %{QUERY_STRING} . [NC]
RewriteRule (.*) - [R=404,L]
Rohit Gupta
  • 4,022
  • 20
  • 31
  • 41
asilv733
  • 19
  • 2