In message <4a0828f2.7020...@ironivyinc.com>, Kal Durak <kal.du...@ironivyinc.com> writes >Jim Mullen wrote: >> You could use the $_SERVER['HTTP_HOST'] variable. >> >> Best regards, >> Jim Mullen >> Web: http://www.iDimensionz.com >> Twitter: http://twitter.com/iDimensionz >> >> Kal Durak wrote: >> >>> I am running virtual servers under Apache. I have an application that >>> needs to run under several of the servers. I need it to retrieve the >>> hostname that it is running under. >>> >>> I noticed that if you run phpinfo.php, under apache2handler, there is >>> a listing for hostname. This is exactly what I need, but I haven't >>> been able to find how to retrieve that variable. >>> >>> Any help would be greatly appreciated. >>> >This gets close, but doesn't quite do it. If my domain is >www.domain.com, I want a response of domain.com. >I tried simply using an if statement, but I the value is the same for >each domain. In other words, if my domains are www.domain1.com >www.domain2.com, both domains give me www.domain1.com. I think what is >happening is that the first domain that runs stores the value. Is there >a way to flush a variable?
The first domain that runs it "could" store it. But the second domain would never be able to see it. That would only happen if you were still looking at the same domain. So in your case, it can't be that. You can't cache a value from one domain, and see it in another. There is something wrong with your code. It certainly works, because I use something similar all the time, so that I can set things like database connections, or Google Maps IDs, which have to be different between the live and development versions. Here is an example (the real code is longer, because I keep it all the variables in one place). I have my development machine set to run the development version on my Windows PC when I type http://b1 into Firefox. If there is ever any doubt as to where the script is running, it runs in live (more secure) mode. if ($_SERVER["HTTP_HOST"]=='b1') { $server = "localhost"; $user = "root"; $pass = ""; $environs = 'dev'; } else { $server = 'localhost'; $user = 'ctrmfqh'; $pass = 'd89gf1ee'; $environs = 'live'; } Then I can do things like, when the system should be sending an email: if ($environs=='dev') then display the contents of the email on screen else send the email In your case, you should have if ($_SERVER["HTTP_HOST"]=='www.domain1.com') { You don't have just a single =, do you? -- Pete Clark Got any spare time? Anything you need? Barter in Spain Join for free at http://BarterWithBart.com