Apache + PHP: how to change the value of $ _SERVER ['SERVER_NAME'] in apache?

for example, I have mysite.com and beta.mysite.com . both point to the same index file using the virtualHost directive. what will i do in apache conf so that when accessing $_SERVER['SERVER_NAME'] value would still be mysite.com ?

it needs to be flexible to remove only beta .

+4
source share
2 answers

Perhaps you could use ServerAlias ​​in your VirtualHost directive and use only one VirtualHost directive:

 <VirtualHost *:80> ServerName mysite.com ServerAlias beta.mysite.com ... </VirtualHost> 
+4
source

http://httpd.apache.org/docs/2.2/mod/core.html#usecanonicalname

Try the following:

 <VirtualHost *:80> ServerName mysite.com ServerAlias beta.mysite.com UseCanonicalName On </VirtualHost> 

I assume that you have 1 VH, not: 1 for each site (since this is the same site).

Restart apache after.

+3
source

All Articles