Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.htaccess-Password is blocking cURL

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 ?

like image 450
GeneralError Avatar asked Jan 06 '23 02:01

GeneralError


1 Answers

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");
like image 190
imkingdavid Avatar answered Jan 08 '23 15:01

imkingdavid