6

Does anyone know how to enable a PHP extension within the .htaccess file?

Possibly:

(.htaccess file)
php_value extension=php_soap.so
1
  • Did you try your example? That would also be my best guess.
    – halfdan
    Dec 15, 2009 at 22:07

3 Answers 3

2

It's exactly the same syntax as Apache's httpd.conf, so it's:

LoadModule php_soap modules/php_soap.so

(for the "modules" bit, I'm assuming you're using the normal modules directory from /etc/httpd. If not, put that directory in it's place.) (Wrong)

It's not a module, as I'd originally thought, but a php extension. Extensions have the following syntax:

extension=soap.so (also wrong)

Apparently it's:

php_extension soap.so

Got that from this thread in a Drupal forum. Ymmv. I'm going home now, since clearly my brain is shot for the day.

Also, make sure you allow for override, or the webserver will ignore your .htaccess file.

2
  • yes, your head. proposed directive will not work
    – user61228
    Mar 26, 2011 at 4:34
  • Hope you got your head checked out! ;) php_extension soap.so doesn't seem to work for me. I believe it must be prefixed with php_value as shown in another answer here.
    – rinogo
    Oct 15, 2020 at 22:25
0

According to the manual the extension keywork can only be used in the php.ini file.

But you could do this in your .htaccess file....

php_value auto_prepend_file /path/to/loadsoap.php

....and in /path/to/loadsoap.php...

<?php

dl(init_get("extension_dir") . "/php_soup.so");
-1

it depends on your php version and your OS.

e.g. in older php versions you must do

php_value php_extension php_curl.so

in linux and

php_value php_extension php_curl.so

in windows. But in php 7 you can do

php_value php_extension curl

and it works for windows and linux as well. For the php versions you could add blocks like this:

<IfModule mod_php5.c>
    php_value php_extension php_curl.so
</IfModule>

<IfModule mod_php7.c>
    php_value php_extension curl
</IfModule>

But unfortunally I dont know a way to check for windows or linux in .htaccess. So you must eccept that the most hosted servers are linux you have the rar situation that your server runs in windows. you must change php_curl.so into php_curl.dll

UPDATE: I noticed today, that php_value php_extension curl has no effect on the modules when using Apache/2.4.41 (Win64) and PHP/7.3.13, I am not sure which versions are affected by this problem.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .