Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

A mod_alias newbie here.

I found the rewrite rule below somewhere and have been using it to block bots and hackers that hit my site, looking for directories like HNAP1, wp, blog, etc.

And it works for that, returning a Forbidden 403 message.

<IfModule mod_alias.c>

RedirectMatch 403 /(\{\$itemURL\}|cro|HNAP1|wp|blog|)/?$

</IfModule>

But how do I also redirect /wp/wp-admin/ and /blog/wp-admin/ to a 403 message? And any other subdirectory, i.e. /wp/wp-admin/subdirectory/ ?

share|improve this question
up vote 1 down vote accepted
+50

You should be able to add more patterns:

RedirectMatch 403 /(\{\$itemURL\}|cro|HNAP1|wp|blog|wp/wp-admin|blog/wp-admin|wp/wp-admin/.+|)/?$

Hope this helps.

share|improve this answer
    
You're right; very useful. I didn't realize it was that easy. Thanks! – markratledge Jul 4 '14 at 21:05
    
FYI, I have to wait a day to award the bounty.... – markratledge Jul 4 '14 at 21:07
    
No problem. Glad it helped! – Belmin Fernandez Jul 4 '14 at 21:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.