Htaccess how to block unwanted url with pattern

I want to block some url and return 401 error. This are the url's i want to block. But this is a just pattern.

mysitecom/?p=lancel%20soldes%20amazon%20canada
mysitecom/?p=lancel%20soldes%20kartell%20table%20basse
mysitecom/?p=prix+sac+la+charmeuse+de+lancel
mysitecom/?lancel=bb-prix-wii-fit
mysitecom/page/2/?p=lancel%20soldes%20caroll%20rouen

Maybe first condutions could be

/?p=
/?lancel
/page/2/?p

how can i block this type urls with htaccess?

Upvotes: 0

Views: 731

Answers (1)

Jon Lin
Jon Lin

Reputation: 143856

How about:

RewriteEngine On
RewriteCond %{QUERY_STRING} (?:^p=|lancel)
RewriteRule ^ - [L,R=401]

Last line can also be:

 RewriteRule ^ - [L,F]

for a 403 response

Upvotes: 1

Related Questions