使用Apache的网站的多个版本,每个版本都有自己的根目录

使用Apache的网站的多个版本,每个版本都有自己的根目录,apache,web,directory,root,Apache,Web,Directory,Root,我的网站有多个版本。每个文件夹都位于自己的文件夹中,例如: site_v1/ index.html page1.html site_v2/ index.html page1.html 如何配置apache,使站点的每个版本都有自己的根目录定义 换句话说,我希望site_v1/index.html认为根目录是site_v1,site_v2/index.html认为根目录是site_v2,您正在寻找VirtualHost指令 您正在查找VirtualH

我的网站有多个版本。每个文件夹都位于自己的文件夹中,例如:

site_v1/  
  index.html  
  page1.html    

site_v2/  
  index.html  
  page1.html  
如何配置apache,使站点的每个版本都有自己的根目录定义


换句话说,我希望site_v1/index.html认为根目录是site_v1,site_v2/index.html认为根目录是site_v2,您正在寻找
VirtualHost
指令


您正在查找
VirtualHost
指令


正如@Pekka所写,您确实在寻找
VirtualHost
指令,但我想我可能会为您的虚拟主机配置添加一个示例配置。这应该放在您的
httpd.conf
文件中,根据您的喜好进行编辑,并记住填写完整路径:

NameVirtualHost v1.yoursite.com:80
<VirtualHost v1.yoursite.com:80>
    ServerName v1.yoursite.com
    ServerAlias v1.yoursite.com
    DocumentRoot /path/to/site_v1
    ErrorLog /path/to/prefered/error.log
    CustomLog /path/to/prefered/access.log combined
    <Directory /path/to/site_v1>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

NameVirtualHost v2.yoursite.com:80
<VirtualHost v2.yoursite.com:80>
    ServerName v2.yoursite.com
    ServerAlias v2.yoursite.com
    DocumentRoot /path/to/site_v2
    ErrorLog /path/to/prefered/error.log
    CustomLog /path/to/prefered/access.log combined
    <Directory /path/to/site_v2>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>
NameVirtualHost v1.yoursite.com:80
ServerName v1.yoursite.com
ServerAlias v1.yoursite.com
DocumentRoot/path/to/site\u v1
ErrorLog/path/to/prefered/error.log
CustomLog/path/to/prefered/access.log组合
选项索引跟随符号链接多视图
不允许超限
命令允许,拒绝
通融
nameVirtualHostV2.yoursite.com:80
ServerName v2.yoursite.com
ServerAlias v2.yoursite.com
DocumentRoot/path/to/site\u v2
ErrorLog/path/to/prefered/error.log
CustomLog/path/to/prefered/access.log组合
选项索引跟随符号链接多视图
不允许超限
命令允许,拒绝
通融

如果需要,您可以选择对站点的每个版本使用不同的访问/错误日志。只需更改日志文件的名称/路径,就完成了
/path/to
是指向站点文件夹的路径,v1.yoursite.com和v2.yoursite.com应更改为每个版本要使用的相对域。如果您不想更改日志文件,请删除
ErrorLog
CustomLog
指令,我将默认使用httpd.conf中设置的主日志文件,正如@Pekka所写,您确实在寻找
VirtualHost
指令,但我想我可能会为您的虚拟主机配置添加一个示例配置。这应该放在您的
httpd.conf
文件中,根据您的喜好进行编辑,并记住填写完整路径:

NameVirtualHost v1.yoursite.com:80
<VirtualHost v1.yoursite.com:80>
    ServerName v1.yoursite.com
    ServerAlias v1.yoursite.com
    DocumentRoot /path/to/site_v1
    ErrorLog /path/to/prefered/error.log
    CustomLog /path/to/prefered/access.log combined
    <Directory /path/to/site_v1>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

NameVirtualHost v2.yoursite.com:80
<VirtualHost v2.yoursite.com:80>
    ServerName v2.yoursite.com
    ServerAlias v2.yoursite.com
    DocumentRoot /path/to/site_v2
    ErrorLog /path/to/prefered/error.log
    CustomLog /path/to/prefered/access.log combined
    <Directory /path/to/site_v2>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>
NameVirtualHost v1.yoursite.com:80
ServerName v1.yoursite.com
ServerAlias v1.yoursite.com
DocumentRoot/path/to/site\u v1
ErrorLog/path/to/prefered/error.log
CustomLog/path/to/prefered/access.log组合
选项索引跟随符号链接多视图
不允许超限
命令允许,拒绝
通融
nameVirtualHostV2.yoursite.com:80
ServerName v2.yoursite.com
ServerAlias v2.yoursite.com
DocumentRoot/path/to/site\u v2
ErrorLog/path/to/prefered/error.log
CustomLog/path/to/prefered/access.log组合
选项索引跟随符号链接多视图
不允许超限
命令允许,拒绝
通融
如果需要,您可以选择对站点的每个版本使用不同的访问/错误日志。只需更改日志文件的名称/路径,就完成了
/path/to
是指向站点文件夹的路径,v1.yoursite.com和v2.yoursite.com应更改为每个版本要使用的相对域。如果不想更改日志文件,请删除
ErrorLog
CustomLog
指令,我将默认使用httpd.conf中设置的主日志文件