.htaccess: Invalid command

I need temporarily put up an old page on the website. However, for that I need register_globals on. So i set .htaccess the following text:
[code]php_value register_globals = 1[/code]
But what i got is error page 500. Go to error log and i found this:
[code][Apr 9 08:31:04 2008] [alert] [client xx.xxx.xx.xx] /home/xxx/public_html/.htaccess: Invalid command ‘php_value’, perhaps mis-spelled or defined by a module not included in the server configuration
[Apr 9 08:18:51 2008] [alert] [client xx.xxx.xx.xx] /home/xxx/public_html/.htaccess: Invalid command ‘php_flag’, perhaps mis-spelled or defined by a module not included in the server configuration[/code]
As you can see, i got the same error for php_flag too. What am I missing?

Googling!! and hit, I’m feeling lucky!!
Yupz, i’m lucky enough and i found that my server now have PHPSUEXEC enabled.

What is PHPSuexec?

PHPSuexec is the shortened term often used to describe running PHP as a CGI with Suexec. Running PHP as a CGI with Suexec creates a much more secure environment compared to running PHP as an Apache module.

Thats why ‘php_value/flag’ no longer works. So the solution is create a php.ini file and set it like this:
[code]register_globals=1[/code]

There is one main difference to the use of .htaccess vs php.ini — a .htaccess file can be placed at the root directory and effect subdirectories with just 1 file, php.ini does not work this way.

A php.ini file needs to be placed in every directory and subdirectory that requires the altered directives. This is a downfall for using PHPSuexec, however i hope that in the future PHP can be written to handle the php.ini file in a more workable fashion.

6 thoughts on “.htaccess: Invalid command”

  1. isn’t that should be:
    php_value register_globals 1

    added for module checking it should be:

    php_value register_globals 1

    php_value register_globals 1

    php_value register_globals 1

  2. Kayaknya bukan masalah apa2. Tergantung setting apache juga (httpd.conf ato apache.conf), settingan yang boleh dioverride apa aja (AllowOverride). Dulu aq pernah setting kayak itu juga buat nggedein php_upload_maxsize n post_maxsize, hasilnya nihil lewat .htaccess. Coz emang ternyata dari pihak hostingnya sendiri yang tidak memperbolehkan. Lewat fungsi ini_set() pun juga nggak mempan. Hack aja hostingnya :)) .

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.