I love using .htaccess to password safeguard a directory, especially because it recursively safeguards all subdirectories too. However, I dislike the ugly login popup you receive each time. Rather than using fundamental auth Let me use mod_rewrite (or similar) to password safeguard a directory (and all sorts of subdirectories) but possess a simple html login for run by php rather.

Ideas?

no... there's not a way to make use of "fundamental authentication" with custom forms as this is done completely through the browser.

There's a workaround by delivering an AJAX request (which works JS-internally and doesn't popup a window) from the form:

  $.ajax({
     type: 'POST',
     url: 'login.php'
     username: $('input#user').value,    // form fields
     password: $('input#pw').value,
  });

The browser keeps the qualifications cached for subsequent, normal GET demands.

(Logging from a HTTP auth is considerably more complicated.)