How can I enable PHP dynamic extensions via the .htaccess file?

Posted on 2007-10-11
Last Modified: 2011-10-03
I'm using shared hosting on a Linux Server running Apache and I want to enable mysqli, which is a dynamic php extension.
My hosting company has told me I can do ..and I quote :

"All of those directives are customizable from a .htaccess file you must create and place in the directory you wish to affect the change on."

I've searched around and haven't found any examples of doing this.
Can anyone help me out with the necessary .htaccess lines necessary to do this?

Also, when I enable msqli locally on my WAMP server, the service restarts. Does this mean I'm going to have to try to find a way to reboot my hosted server as well or is it only the W in WAMP that necessitates a restart?

Thanks in advance
Question by:cgarvey
    LVL 48

    Accepted Solution

    Extension can't be enabled via a .htaccess
    How  to change other settings via .htaccess and php.ini sSee

    you might modify the software to automaticly load extension from within php like this:
    LVL 9

    Expert Comment

    Or just


    no need of PEAR here
    LVL 48

    Expert Comment

    dl("mysql"); is not sufficient. It depends on the running os. For windows you need:
    for Linux
    And thats what you don't need to care about if you use pear.

    LVL 9

    Expert Comment


    Yes, you are completely right that you should provice library name there, so it should be :

    if ( !extension_loaded('mysqli')) {
      if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
      else {

    or eveny simplier :

    if (!extension_loaded('mysqli')) {
        $prefix = (PHP_SHLIB_SUFFIX === 'dll') ? 'php_' : '';
        dl($prefix . 'mysqli.' . PHP_SHLIB_SUFFIX);

    Examples taken from
    LVL 1

    Expert Comment

    Forced accept.

    EE Admin

    Featured Post

    Gigs: Get Your Project Delivered by an Expert

    Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

    Join & Write a Comment

    Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
    Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
    The viewer will learn how to count occurrences of each item in an array.
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now