I'm using WordPress and I have some duplicate URL by spammer
https://www.example.com/caterory/article-name/
==> OK
https://www.example.com/caterory/article-name/?vn/2022-06-24fivhg585.html
==> Wrong
I would like to block this kind of URL with string ?vn/
I tried this but it's not working
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} (googlebot|bingbot) [NC]
RewriteCond %{QUERY_STRING} ^*vn/ [OR]
RewriteCond %{REQUEST_URI} ^*vn/
RewriteRule ^ - [F]
Any ideas?
The following should work for you. Make sure to place it at the top or before your WP rewriterule block .
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} (googlebot|bingbot) [NC]
RewriteCond %{QUERY_STRING} ^vn/ [NC]
RewriteRule ^ - [F]
If you want to test this rule yourself , just comment out or remove the condition line RewriteCond %{HTTP_USER_AGENT} (googlebot|bingbot) [NC]
and visit any URL starting with the querystring ?vn
. You will get a 403 forbidden error.