Monthly Archives: October 2015

Apache: How to block all other IPs except for your own

Sometimes I have to work on WordPress sites that are too busy to display the admin interface. This can happen if there’s more traffic than the server can cope with. In such cases, we may need to tell every visitor to come back later while we carry out some maintenance.

But how? Thanks to an Apache command to block all IP addresses, except for our own. We can even display a “maintenance” page while we’re hard at work behind the scenes.

Let’s see how. Add the following to your .htaccess file in the web root directory, replacing 12.34.56.78 with your own IP address:

Save the file on the server and see the site speed up as of by magic. No more requests but your own shall be processed henceforth.

Thanks to MickeyRush and b101101011011011 for this solution on Stack Overflow:

  • http://stackoverflow.com/questions/4400154/htaccess-deny-all-allow-only-one-ip

How do I find my own IP?

There are several services that will display the IP you’re currently connecting from. Head over to http://whatsmyip.org, or type “my ip” into Google.

Does this work with NGINX too

I’m sure the principle does, but I know very little about NGINX configuration. The above directive is for Apache only. If you know how this works in NGINX, please leave a comment below.

How to move the sidebar to the right in TwentyFifteen

I’ve never liked themes with sidebars on the left – probably because we in the western world start reading on the left, and I’d like there to be as little clutter as possible. Or perhaps I’m used to navigation items on the right.

I was looking around for solutions to move the sidebar in Automattic’s TwentyFifteen theme to the right, and several options can be found on the internet. Here are two that worked for me:

Option 1: CSS Tweak

Thanks to the Stack Exchange community, this CSS tweak works a treat (for left-to-right languages):

Add these declarations to your own TwentyFifteen Child Theme and you’re good to go. If added via a CSS widget or to the bottom of the original theme (which is a really bad idea), additional “!important” statements may be necessary.

Kudos to toschero and Anteru for the combined solution to this puzzle. Check out the full discussion here:

  • http://wordpress.stackexchange.com/questions/173783/how-to-move-the-sidebar-in-twentyfifteen-to-the-right

Option 2: Pre-made Child Theme

Ruhul Amin from Tips and Tricks HQ has built a ready-to-use child theme and solved this puzzle in PHP. You can check it out here:

  • https://www.tipsandtricks-hq.com/wordpress-twenty-fifteen-2015-child-theme-with-right-sidebar-7732