I like using .htaccess to 开发者_如何学运维password protect a directory, especially since it recursively protects all subdirectories as well. However, I despise the ugly login popup you get everytime. Instead of using basic auth I'd like to use mod_rewrite (or similar) to password protect a directory (and all subdirectories) but have a simple html login for powered by php instead.
Ideas?
no... there is no way to use "basic authentication" with custom forms since this is done completely by the browser.
There is a workaround by sending an AJAX request (which works JS-internally and does not popup a window) from a form:
$.ajax({
type: 'POST',
url: 'login.php'
username: $('input#user').value, // form fields
password: $('input#pw').value,
});
The browser keeps the credentials cached for subsequent, normal GET requests.
(Logging out from a HTTP auth is significantly more complex.)
精彩评论