Setting environment variable using .htaccess
Asked Answered
P

1

10

I'm trying to set up an apache environment variable using .htaccess file in the following way:

SetEnv SERVER_KEY "qwerty"

After that i gracefully restart my apache web server:

apachectl graceful

Then i create a file called version.php in /var/www/html

<?php phpinfo() ?>

And go to MYIPADDRESS/version.php to check but i find out that the environment variable has not been set up.

Here are further details: OS: RHEL6 PHP Version: 5.3.3 Apache Version: 2.2.15 (Red Hat)

What do i do?

Update: I solved my problem by changing AllowOverride None to AllowOverride All in the server configuration file!

Pearl answered 10/7, 2013 at 21:20 Comment(0)
F
11
  1. Check that the htaccess is being read at all, make sure you've configured your host so that it allows (at the very least) "FILEINFO", or better yet, set it to "ALL"

    AllowOverride ALL
    
  2. If not, make sure your mod_env module is being loaded in your server config.

  3. Make sure you're looking in the right place. Apache internal environment variables are passed along to php via the $_SERVER[] array (on the phpinfo() page, under Apache Environment) and they are different from php runtime environment variables.(which are under Environment),

Frigg answered 10/7, 2013 at 21:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.