我如何让Apache知道要使用不同的域哪个应用目录? [英] How do I make Apache know which app directory to use for different domains?
问题描述
我试图创建codeIgniter的网站。我将不得不从该服务器提供服务的多个域和我所试图做的是从药粥www.example1.com的HTTP请求分离为www.example2.com,然后将其重定向到其正确的应用程序文件夹。
I'm trying to create a site with CodeIgniter. I will have multiple domains served from this server, and what I am trying to do is to separate the HTTP requests for www.example1.com from the ones for www.example2.com and then redirect them to the their correct application folders.
说这是我的目录结构:
- 系统
- 申请
- 例1
- 示例2
因此,这要求
www.example1.com/gallery/
www.example1.com/gallery/
随后将被重定向到exmaple1夹
would then be redirected to exmaple1 folder.
有没有人有这样做的任何code的例子吗?很明显,你需要使用重写模块...
Does anyone have any code example for doing this? Obviously you would need to use the ReWrite module...
我看了Apache文档左右,但我无法得到任何地方。让我知道如果你需要更多相关信息。
I looked around the Apache documentation but I couldn't get anywhere. Let me know if you need more information on this.
推荐答案
使用虚拟主机(和别名,重写)是主要的答案,但如果你认为你将增加/使用相同的设置删除其他主机,那么我会考虑 mod_macro 模块。这是一个第三方的模块,这将帮助您简化Apache配置,避免复制/粘贴错误。
Using VirtualHost (and Alias, Rewrite) are the primary answers, but if you think you will be adding/removing other hosts using the same setup, then I would consider the mod_macro module. This is a third party module that will help you to simplify apache configuration and avoid copy/paste errors.
与布局一个简单的例子,定义如下:
A simple example with your layout, define the following:
<Macro vh80 name> <VirtualHost *:80> DocumentRoot /system/application/$name ServerName www.$name.com CustomLog /system/application/$name/logs/access.log virtcommon ErrorLog /system/application/$name/logs/error.log </VirtualHost> </Macro>
和再启用一个网站时,请使用以下指令:
And then when enabling a site, use the following directive:
使用vh80例1
这将设置www.example1.com使用配置目录根目录以及配置的日志目录。
Which will setup www.example1.com to use the configured directory as root as well as the configured logging directory.
这篇关于我如何让Apache知道要使用不同的域哪个应用目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
- 申请