Mac Brian
Mac Brian

Reputation: 1

Non existent pages to error page htaccess file

I was trying to write rewrite rule to return 404 on urls with spam parameters. I used the following rewrite tool to return error 404 with query string voxter.pdf&gpvoq and parameters gpvoq but its not producing 404 error.

RewriteCond %{voxter.pdf&gpvoq} (^|&)parm1=gpvoq [NC]
RewriteRule  (.*)/error-404.php? [R=404,L]

Can u please help me what mistake I am doing?

Upvotes: 0

Views: 37

Answers (1)

Jon Lin
Jon Lin

Reputation: 143886

%{voxter.pdf&gpvoq} isn't an apache variable. That will only match itself as a literal. You need to be using the %{QUERY_STRING} variable instead:

RewriteCond %{QUERY_STRING} (voxter.pdf|gpvoq) [NC]
RewriteRule  ^ /error-404.php? [R=404,L]

or some similar regex.

Upvotes: 1

Related Questions