Once again, I created a WordPress plugin based on my own needs. This one allows you to test your website on your local server environment without worry that somebody is trying to access it from the outside.

It only allows ‘http://localhost’ and ‘http://127.0.0.1′ as the URL and will deny any attempt to use your server’s IP address (i.e. http://123.45.67.89). It prevents nosy people from seeing what your next website will look like before it’s ready! ;)

This is the first official WordPress plugin that I’ve made. It follows the WordPress plugin guidelines and can be activated easily on the plugin page.

To intall:

  1. Unzip
  2. Upload to plugin directory (wp-content/plugins)
  3. Activate via the plugin interface in the admin panel

Customizing: You can customize this plugin to do just about anything. You can redirect the visitor to another webpage, output an error message, or just leave it as it is and provide a blank page.

You can download it here:

Localhost Restricter Version 1.0

If there are any questions or comments, please reply to this topic in the comments below.

7 Responses to “My New WordPress Plugin: Localhost Restricter”

  1. Date Heure Says:

    Nice one! I normally do that in my apache config file when working on a website locally (I use EasyPHP to run apache, php and mySQL on Windows). This is a great idea though for wordpress-based websites.

  2. Nate Olson Says:

    Thanks for making this publicly available, Trevor. Sounds quite useful, and I’ll certainly give it a test as I’m in need of something like this just now.

    Cheers,

    Nate

  3. dave Says:

    Excellent, I’ve done this manually before int he header php file but to have a customisable script as a plugin is great.

    Some I’d really like which I can’t work out how to do is to use such a script to block access from any client, but allow from my server.

    I use Joomla as my CMS but then I stumbled on WordPress (a while ago) so I opted for WP as my blog and Joomla for everything else, I run WP via the Joomla wrapper module (iframe)

    It would be great to block any attempting http://site.com/blog and allow any clicking on the wrapper link to go to the same URL.

    I can get it working with http_referrer fine, but then once loaded all WP links and menus are blocked because its client based.

    but anyway, thanks for the plugin.

    (ps, yes I’m complete newb learning as I go, so I probably don’t have the right understanding of the functions of http_server and http_referrer)

    cheers
    dave

  4. CIO Jerry Says:

    For a self-hosted blog server, it’d be safer & cleaner to stop it at network perimeter (a router, a firewall or a proxy server). To name a few, iptables on Linux and Windows Firewall on Windows, or other firewall of your choice, squid rules.

    Short of that, apache’s ‘deny from’ directive should works great too, in the main httpd.conf or local .htaccess.

    The plugin should be only be necessary when you are in a hosted environment when you don’t have control over the above layers of defense.

  5. Trevor Fitzgerald Says:

    Jerry,

    I agree and I actually do the same thing. I use an .htaccess file to deny access from anyone but myself.

    < Files "*" >
    order deny,allow
    deny from all
    allow from 127.0.0.1
    < /Files >

    ^ Works perfectly. (minus the spaces before and after the tags because I can’t post tags in the comments here).

    However, this plugin accomplishes pretty much the same thing. I suppose I could make it so that it restricts access based on IP address, too, and not just the URL.

    Thanks,
    Trevor

  6. John Says:

    Or simply block outside access using XAMPP.

  7. Gary Olson Says:

    Great Job Here…I enjoyed it..! Gary

Leave a Reply