1

I am trying to enable curl in the .htaccess file.

The reason for this is this error I got:

Warning: curl_exec() has been disabled for security reasons in [PATH] on line [LINE] 

And i don't have access to the php.ini file (I use shared hosting). My host says that I can enable curl using .htaccess but I have no clue how.

I have absolutely no experience with .htaccess so keep that in mind.

Thanks!

JordyAlkema
  • 41
  • 1
  • 7
  • 1
    Why would someone disable it, when you can easily enable it afterwards. I mean, you cannot. – Daniel W. Mar 05 '15 at 21:39
  • add `php_extension libcurl.so` or `php_extension curl.so` –  Mar 05 '15 at 21:40
  • @Dagon As you can see from the error message, PHP is aware of the curl extension but cannot execute the function curl_exec() – AlexL Mar 05 '15 at 21:41
  • 1
    You might still be able to have `php.ini`-overrides. Check your `phpinfo()` result. See here: http://stackoverflow.com/questions/17688944/overriding-php-ini-in-a-shared-development-environment – Dai Mar 05 '15 at 21:44

3 Answers3

4

To be able to change any option through .htaccess at all, your server administrator needs to configure your virtual host with

AllowOverride Options

Options passed with php_admin_value cannot be overwriten in .htaccess at all.

Not all options can be changed during any stage, disable_functions can only be overwritten in php.ini (see http://php.net/manual/en/ini.list.php), not in .htaccess.

So you have no chance to enable curl. Maybe talking to your hoster helps.

HavelTheGreat
  • 3,299
  • 2
  • 15
  • 34
Daniel W.
  • 31,164
  • 13
  • 93
  • 151
0

You must use phpinfo() function to see disable_functions parameter.

Then you can enable it removing it from list with this line of .htaccess:

<IfModule mod_php5.c>
    php_value disable_functions "all of them without curl_exec"
</IfModule>

Further reading: http://php.net/configuration.changes

Edit: This is not possible outside of php.ini

As seen in http://php.net/manual/es/ini.core.php#ini.disable-functions -> disable_functions (php.ini only).

disable_functions (string)

This directive allows you to disable certain functions for security reasons. It takes on a comma-delimited list of function names. disable_functions is not affected by Safe Mode.

Only internal functions can be disabled using this directive. User-defined functions are unaffected.

This directive must be set in php.ini For example, you cannot set this in httpd.conf.

Talk your web hosting provider about this problem.

Best regards,

OscarGarcia
  • 1,995
  • 16
  • 17
-2

This might work, but it might be nice to see what other functions have been disabled for security reasons.

In .htaccess:

php_admin_value disable_functions " "
kylehyde215
  • 1,216
  • 1
  • 11
  • 18