apache 基于ip的虚拟主机配置(虚拟主机设定不同的字符编码)

<Directory "D:/EmpireServer/web">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.2/mod/core.html#options
    # for more information.
    #
    Options FollowSymLinks

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride None

    #
    # Controls who can get stuff from this server.
    #
    Order allow,deny
    Allow from all

</Directory>




<Directory "D:/EmpireServer/weibo">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.2/mod/core.html#options
    # for more information.
    #
    Options FollowSymLinks

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride None

    #
    # Controls who can get stuff from this server.
    #
    Order allow,deny
    Allow from all

</Directory>
<VirtualHost 192.168.2.40:82>
    ServerAdmin      cms@G2.home
    DocumentRoot     "D:/EmpireServer/web" 
    ServerName       cms
</VirtualHost>

<VirtualHost 192.168.2.54:82>
    ServerAdmin      weibo.home
    DocumentRoot     "D:\EmpireServer\weibo" 
    ServerName       weibo
</VirtualHost>

为不同的虚拟主机设定不同的字符编码

不同需求 
因为服务器上有很多虚拟主机,而有些虚拟主机需要UTF-8编码支持,一些需要GB2312编码支持。

运行环境 
ubuntu7.04
Apache-2.2.3
碰到问题 
在apache2的全局设置里,设置了默认字符集为UTF-8,而一些需要GB2312支持的网站,在访问的时候,就出些乱码。

AddDefaultCharset UTF-8
解决办法 
修改全局默认字符集为GB2312 
AddDefaultCharset GB2312

原文地址:https://www.cnblogs.com/jifeng/p/2178581.html