Setting Variables with .htaccess


I was thinking a few months ago how handy it would be if I could set server variables with .htaccess.  In particular was the path to which I had installed my customer management software.  Many programs had used its include file, both in the software's directory and outside of it, requiring me to hard-code its path.  And, of course, it is good programming practice NOT to hard-code paths.

I was told then that this was impossible.  I like to think that I am the first to make a great discovery, but it is likely that the person that told me that was just wrong.

SetEnv cm_path /home/mango/public_html/cm

and in PHP, you simply access the cm_path variable like this:

$_SERVER['cm_path']
 
  1. No comments yet.
Allowed HTML: <b>, <i>, <em>, <strong>. All other < and > will be replaced with &lt; and &gt;.