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']
 

If you would like a reply to your comment, you must leave your email address! We receive dozens of questions every month from people who don't leave us with any way to contact them, so we have no choice but to ignore the question. We try to reply to as many questions as we can, if we know the email address of the person who asked the question. Thanks in advance for writing in :)

Allowed HTML: <b>, <i>, <em>, <strong>. All other < and > will be replaced with &lt; and &gt;.