Using PHP to access a file protected by .htpasswd

Hey guys,

Is there a way to use PHP to redirect to a page that’s in a folder protected by .htpasswd, without the user having to enter any info?

Basically, I have a bunch of database function PHP files, all within a folder protected by .htpasswd. I want to be able to access one of those files’ functions through ajax from a public page. I’m thinking I could create an intermediary PHP page that the ajax accesses, that has the username and password hard-coded into it somehow, which would allow it to pull info from the .htpasswd-protected file(s).

Does that make sense? Any idea how I’d go about this?

Any security issues I should watch out for? For instance, once that protected file was accessed, would a user then be able to just go into any protected file they wanted after that (like when you already enter the username and password once, and you aren’t prompted again as long as your browser stays open)?

Thanks :beer: