當 php.ini 的 register_globals 值為 Off,如何在不更改 php.ini 的情況下更改預設值

測試環境

Fedora Core release 6 (Zod)

Apache

Server version: Apache/2.2.6 (Unix)

PHP 4.x

方式一
   vi /etc/httpd/conf/httpd.conf

<Directory /var/www/html/test>
   php_flag register_globals On
</Directory>

方式二
   在 /var/www/html/test/ 底下放入 .htaccess
   但前題要在 /etc/httpd/conf/httpd.conf 設定

<Directory /var/www/html/test>
   AllowOverride All
</Directory>

   vi /var/www/html/test/.htaccess

php_flag register_globals ON

   以上就會在 phpinfo 中得到

register_globals On Off

其它應用

<Directory /var/www/html/test>
   php_admin_value sendmail_path '/usr/sbin/sendmail -t -i -f cross@ssorc.tw'
</Directory>

   改完後,會由

sendmail_path /usr/sbin/sendmail -t -i  /usr/sbin/sendmail -t -i 

   變成

sendmail_path /usr/sbin/sendmail -t -i -f cross@ssorc.tw /usr/sbin/sendmail -t -i 

如果情況為
      httpd.conf

<Directory /var/www/html/test>
   php_flag register_globals Off
   AllowOverride All
</Directory>

      .htaccess

php_flag register_globals ON   

      優先權就交由 .htaccess 了

   但如果管理者要把權限拿回來呢
   在 httpd.conf 設定 php_admin_flag

<Directory /var/www/html/test>
   php_admin_flag register_globals Off
   AllowOverride All
</Directory>

備註
   php_admin_flag 不能用於 .htaccess
   php_admin_flag 的權限大於 php_flag

ref: http://203.68.102.46/big5_php_manual/configuration.changes.html

Related posts 相關文章
WordPress 6.3 以後可能不支援 PHP 5,最低需求為 PHP 7.4
More...
你的 WordPress 升級到 PHP 8 了嗎
More...
你看 WordPress 也建議至少 PHP 7.4+ 了
More...
PHP 7 最後一版,今年也要退場了
More...

作者

留言

撰寫回覆或留言

發佈留言必須填寫的電子郵件地址不會公開。