How to redirect site to 403 if a certain url get v

2019-08-06 16:46发布

In my site statistics, I'm staring to get strange URLs like these:

mysite.com/?p=casino-online-spielen

mysite.com/category/page/2/?p=casino-online-spielen

I've tried rewrites but it has messed up my WordPress rewrites or just didn't work. I am not that good in htaccess or apache.

<IfModule mod_alias.c>
RedirectMatch 403 ?p=(casino|pharmacy)
</IfModule>

What I need is a htaccess rule that sends the user to 403 error if the word casino is found, or better yet if ?p= is found in the URL, which is not supposed to happen. But I fear it will destroy archive pagination.

On the other hand, it should allows ?s= variables and whatever is in it.

1条回答
【Aperson】
2楼-- · 2019-08-06 17:38

Essentially follow @Starkeen suggestion and use mod_rewrite eg.

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{QUERY_STRING} p=(casino|pharmacy) 
  RewriteRule .* - [F,L]
</IfModule>

Note:

  • F = Forbidden = 403
  • L = Last = Just doooooo IT.
查看更多
登录 后发表回答