I did local tests, it should be working fine.
did you put above code in /home/user/public_html/.htaccess ?
another case is, if you have accessed /private/ first, and input the user name / password, browser will remember them, when you visit /private/index.php, it won't prompt you...