Home > TechStuff, TricksAndTips > WordPress Multisite IP block

WordPress Multisite IP block

January 20th, 2011 Leave a comment Go to comments

I have a case where a customer wants to block one of their many WordPress multisite blogs from all but some IP ranges. It turned out this could be quite easily solved with mod_rewrite in Apache – I know, the correct way to do it would probably be to set up a seperate virtualhost for that one URL and use allow from, but in a Plesk environment this is not always so easy…

The blog URL is intranet.domain.tld, and the allowed IPs should be 12.34.32.10 and the range 23.45.54.0/24. If the remote IP is not in the allowed range please go read the news…

The following snippet must be placed FIRST in the WordPress multisite .htaccess file

RewriteEngine on
RewriteBase /

RewriteCond %{REMOTE_ADDR} !12\.34\.32\.10$
RewriteCond %{REMOTE_ADDR} !23\.45\.54\..*$
RewriteCond %{HTTP_HOST} "intranet.domain.tld"
RewriteRule .* http://www.reddit.com [last]

Categories: TechStuff, TricksAndTips Tags:
  1. No comments yet.