4

I have locked my development-environment with a .htaccess-password.

While I'm now working on a script that uses a cURL-request to that htaccess-protected-folder, it doesn't work. When I delete the htaccess-protection it works fine.

Is there a way to block UserAgents, like GoogleBot and other human requests, but allow cURL ?

GeneralError
  • 43
  • 1
  • 3
  • 1
    Possible duplicate of [How do I make a request using HTTP basic authentication with PHP curl?](http://stackoverflow.com/questions/2140419/how-do-i-make-a-request-using-http-basic-authentication-with-php-curl) –  May 12 '16 at 14:29

1 Answers1

9

You can define the HTTP Auth username and password like this:

curl -u username:password http://...

This way you don't have to disable the HTTP Auth while accessing it from a browser but can access it from your script.

EDIT: If working with the PHP CURL object you can also define it as such:

curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
imkingdavid
  • 1,411
  • 13
  • 26