How to fix Error 404 when Password Protect a WordPress Subdirectory with .htaccess

When you try to password protect a WordPress subdirectory by adding .htaccess and .htpasswd under subdirectory, you sometimes (in fact most of the times) get Error 404 – Page not found when you visit that subdirectory location in the browser.

To fix this error, add the following line at the top of .htaccess located in the root of your WordPress installation (yes, root .htaccess and not .htaccess of your password protected subdirectory), and you’re good to go now.

ErrorDocument 401 default

Do you have any different solution? I would love to hear your comments.

Fix Error 404 when Password Protect a #WordPress Subdirectory with .htaccess #WordPressTips Click To Tweet

Debug WordPress White Screen of Death and other Errors

After so many requests asking about “WordPress white screen of death”, I would like to quickly share my strategy I use in most of the WordPress installs I manage which allow me to quickly switch on debug mode when required.

In the file wp-config.php, which can be found in your WordPress root, search for variable WP_DEBUG and replace it with

if (isset($_GET['debug']) && $_GET['debug']=='debug_mode') {
    error_reporting(E_ALL); ini_set('display_errors', 1);
    define('WP_DEBUG', true);
}

Now you can open any page, and if something goes wrong there, like a white screen of death, you can add ?debug=debug_mode to the end of its URL and check what’s causing the trouble. Eg. http://www.mywordpresssite.com?debug=debug_mode

I hope this helps.

Best practice on debugging #WordPress White Screen of Death and other Errors #WordPressTips Click To Tweet

How to fix CentOS Yum Error – “4 is not a valid release”

After CentOS 4 hit End of Life in February (No updates after 29 February 2012), you may have noticed the following error coming from the “yum” installer:
not using ftp, http[s], or file for repos, skipping – 4 is not a valid release or hasnt been released yet

However, there is very easy way to get “yum” working again without upgrading everything to newer version of CentOS.

  1. Login to your server/SSH using root
  2. Open /etc/yum.repos.d/CentOS-Base.repo in an editor (vi/vim)
  3. Comment out the “mirrorlist” entries
  4. Uncomment the “baseurl” entries and change them to http://vault.centos.org/4.9/os/$basearch

That’s it!

Fix CentOS Yum Error - '4 is not a valid release' #centos #linux Click To Tweet