"Invalid command 'php_value'" in .htaccess for WordPress site after switching hosts

5,698

It's quite probable you've moved from a host where PHP was installed as an Apache module and is now configured as CGI/FastCGI. Instead of using php_value in .htaccess, you'll need to set these values in a .user.ini file instead. The format is the same as php.ini. (Some hosts also allow a local php.ini as well.)

The .user.ini file (note the dot prefix) goes in the document root of your site, just like .htaccess, but contains just the settings that relate to PHP.

For example, if you previously had something like the following in .htaccess:

# Include a PHP file on every request
php_value auto_prepend_file /home/dotcomwo/public_html/includes/config.inc.php

Then you would write this like the following in a .user.ini file:

; Include a PHP file on every request
auto_prepend_file="/home/dotcomwo/public_html/includes/config.inc.php"
Share:
5,698

Related videos on Youtube

Stephen Ostermiller
Author by

Stephen Ostermiller

Updated on September 18, 2022

Comments

  • Stephen Ostermiller
    Stephen Ostermiller over 1 year

    I moved my site which was on 00webhost to a new host. I set everything up but a 500 internal error shows up.

    The error log reports the following:

    [Sun Feb 11 23:43:59.139864 2018] [core:alert] [pid 549884:tid 140054322136832] [client 77.75.78.164:60560] /home/dotcomwo/public_html/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration

    What should I do to get it working?

    • Admin
      Admin over 6 years
      It would help to post the contents of that .htaccess file here. Please edit your question and include the portions of it with the php_value in them.