.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:
  1. php_value register_globals = 1

But what i got is error page 500. Go to error log and i found this:

CODE:
  1. [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
  2. [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

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:
  1. register_globals=1

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 comments so far

  1. anton ashardi April 27, 2008 7:40 am

    ooooo...gitu tho...

    * pur2 nyambung *

  2. ferdhie April 27, 2008 1:35 pm

    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

  3. ferdhie April 27, 2008 1:36 pm

    [IfModule mod_php4.c]
    php_value register_globals 1
    [/IfModule]

    - its strip all tags

  4. JOKERz April 27, 2008 4:43 pm

    @ferdhie:
    never try that way, as far as i know, if .htaccess contain php_value or php_flag with PHPSUEXEC enable, it will return error 500.

  5. JOKERz April 27, 2008 4:46 pm

    @ferdhie:
    never try that way, but as far as i know, if .htaccess contain php_value or php_flag with PHPSUEXEC enable, it will return error 500.

  6. iroel July 5, 2009 3:34 pm

    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

Please be polite and on topic. Your e-mail will never be published.

:) :( :d :"> :(( \:d/ :x 8-| /:) :o :-? :-" :-w ;) [-( :)>- more »