问题
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:
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.
来源:https://stackoverflow.com/questions/32036831/how-to-redirect-site-to-403-if-a-certain-url-get-variable-exists-or-contains-an