Apache 特定ファイルへのアクセスをIPで制限.htaccess

WordPressの定番アタックを阻止する
wpインストールディレクトリの .htaccessへ追記する

 


<Files ~ "(wp-cron|wp-login|xmlrpc)\.php$">
    Order deny,allow
    Allow from xxx.xxx.xxx.xxx yyy.yyy.yyy.yyy
    Deny from all
</Files>
#アタックの多いファイルは0。0。0。0へリダイレクト
RewriteEngine On
RewriteBase /
RewriteRule ^xmlrpc\.php "http\:\/\/0\.0\.0\.0\/" [R=301,L]
RewriteRule ^wp-cron\.php "http\:\/\/0\.0\.0\.0\/" [R=301,L]
RewriteRule ^xmlrpc\.php "http\:\/\/0\.0\.0\.0\/" [R=301,L]
RewriteRule ^wp\/wp-cron\.php "http\:\/\/0\.0\.0\.0\/" [R=301,L]
RewriteRule ^(.*\.xml)$ "http\:\/\/0\.0\.0\.0\/" [R=301,L]
RewriteRule ^(.*\.gm)$ "http\:\/\/0\.0\.0\.0\/" [R=301,L]

 

xxx yyy は許可するIP
自身のIPは200、不許可IPは403のステータスコードが返される


Categories:

Tags: