Apache - how to map prefixes to different directories

故事扮演 提交于 2019-12-08 00:37:03

问题


Is it possible to configure Apache to allow different prefixes (instead of www) to map to different directories in the file system? For example...

I have two different environments on my webserver:

  /home/me/test/web : Test Environment
  /home/production/web : Production Environment

I would like these to map to these urls:

  test.mysite.com -> /home/me/test/web
  prod.mysite.com -> /home/production/web

However, nothing I've tried with VirtualHosts has worked:

  NameVirtualHost *:80

  <VirtualHost *:80>
      ServerName test.mysite.com
      ** Some SetEnvs **
  </VirtualHost>

  <VirtualHost *:80>
      ServerName prod.mysite.com
      ** Different SetEnvs **
  </VirtualHost>

This throws the following error:

  [warn] _default_ VirtualHost overlap on port 80, the first has precedence

Is this kind of configuration even possible with Apache, or am I doing something wrong? Also, some clarification - simple rewriting with a virtualhosts file probably won't fit either. It works for straight directory stuff, but then I can't use any SetEnv directives like I could within a VirtualHost section.


回答1:


Should be : not .:

NameVirtualHost *:80


来源:https://stackoverflow.com/questions/6942980/apache-how-to-map-prefixes-to-different-directories

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!