开发者

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 the apache conf so that when i access the $_SERVER['SERVER_NAME'], the value w开发者_如何学运维ould still be mysite.com?

this should be flexible that only the beta would be removed.


Maybe you could use a ServerAlias in your VirtualHost directive, and use only one VirtualHost directive:

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


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

Try this:

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

  UseCanonicalName On
</VirtualHost>

I'm assuming you have 1 VH, and not: 1 for each site (since they are the same site).

Restart apache after.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜