简体   繁体   中英

htaccess - Deny access to certain urls but allow others

I'm having a DDoS attack to my wordpress site. Thousands of request to any urls followed by /feed! So I would add a rule on htaccess to to block any request contain "/feed" BUT I need to allow some exceptions that I really cannot block: 1. mysite.com/feed (the main rss feed) 2. mysite.com/category/feed (some specific category feed I use to share)

Is it possible to build a rule like this?

Tnx in advance

Try :

RewriteEngine on

##1##
RewriteRule ^(feed|category/feed)/?$ - [L]
##2##
RewriteRule ^.*feed.*$ - [F,L]

The first rule matches requests /feed or /category/feed and lets them pass untouched. (no rewriting)

The second rule checks if the the requested uri has "/feed" anywhere in the string then forbid the request.

At the moment I'm using FeedBurner as filter, so I let it pass and block others

RewriteCond %{HTTP_USER_AGENT} !FeedBurner RewriteRule feed - [R=403]

Now I would like to implement an ELSE statement to redirect to feedburner all non-feedburner accessing to /feed

  1. FeedBurner -> get access to the feed
  2. /feed redirect to FeedBurner
  3. Any other access containing /feed is forbidden

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM