I need to set SERVER_NAME Apache Environment variable in phpinfo.php. But it is not showing it correctly. I can give "$SERVER_NAME="$HTTP_HOST";" in phpinfo.php file and that value is taken correctly. But the "SERVER_NAME" in the page is not showing it like that.
Does phpinfo() takes the Apache Environment value directly from the apache virtual host entry for that domain? If so how can I make ServerName take the desired wildcard?
The phpinfo.php script is not for setting variables, it is for displaying the current status.
I'm not sure I understand what you mean by 'how can I make ServerName take the desired wildcard?' Please clarify if you have script code you have written and it's not showing you what you expected. If so, then could you post the portion of your code (not the phpinfo.php file).
"The phpinfo.php script is not for setting variables, it is for displaying the current status."
Yes that is what I want.. I want to change the current status of SERVER_NAME.
I have setup wildcards so that when I take anything.mydomain.com, it will be dislayed in the browser. The wild card is applied for the ServeAlias by giving an entry like "ServerAlias *.mydomain.com". I want it to change the ServerName also accordingly..
What I wanted was the ServerName option in apache conf to also take the same value as ServerAlias. That is, for getting the wildcard to work I had modified ServerAlias to take *.domain.com and also added the needed entries in named zone file. This got the wildcard working.
But I wanted apache's ServerName(SERVER_NAME in phpinfo) variable also to take the same thing as ServerAlias(in phpinfo you see this as HTTP_HOST).. If we use abc.domain.com in the browser, I wanted SERVER_NAME variable also to take this same thing abc.domain.com. But somehow apache was letting only the value given for ServerName in httpd conf file to be taken as this variable. and i was looking for a way to change this to take *.domain.com
I am not sure if you understood this. But I will tell you how I got it working. then you will know what I was looking for..
I put "UseCanonicalName" option to "Off" for that particular domain alone. And that enabled ServerName to take the same value as ServerAlias..
Quoting from apache conf file: # UseCanonicalName: (new for 1.3) With this setting turned on, whenever
# Apache needs to construct a self-referencing URL (a URL that refers back
# to the server the response is coming from) it will use ServerName and
# Port to form a "canonical" name. With this setting off, Apache will
# use the hostname:port that the client supplied, when possible. This
# also affects SERVER_NAME and SERVER_PORT in CGI scripts.