My New WordPress Plugin: Localhost Restricter
January 21st, 2007
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:
- Unzip
- Upload to plugin directory (wp-content/plugins)
- 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.
January 22nd, 2007 at 12:27 pm
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.
January 22nd, 2007 at 2:19 pm
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
January 28th, 2007 at 5:04 am
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
February 20th, 2007 at 11:32 am
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.
February 20th, 2007 at 4:27 pm
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
March 24th, 2007 at 2:09 pm
Or simply block outside access using XAMPP.
May 31st, 2008 at 10:16 am
Great Job Here…I enjoyed it..! Gary