Apache配置文件代码段

配置DocumentRoot

# 定义变量
Define WEB_ROOT "E:\workspace\php\MonBook\website"

DocumentRoot ${WEB_ROOT}
<Directory ${WEB_ROOT}>
    #
    # 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.4/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks Includes ExecCGI

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

    #
    # Controls who can get stuff from this server.
    #
    Require all granted
</Directory>

二级目录解析

Alias /simple_blog "E:\workspace\php\simple_blog"
<Directory "E:\workspace\php\simple_blog">
	Options Indexes FollowSymLinks Includes ExecCGI
	AllowOverride All
	Require all granted
</Directory>

二级域名解析

<VirtualHost local-wxadm-test.dymfilm.com:80>
    ServerName local-wxadm-test.dymfilm.com
    ErrorLog "D:\web_root\tmp\local-wxadm-test.dymfilm.com.log"
    CustomLog "D:\web_root\tmp\local-wxadm-test.dymfilm.com-custom.log" combined
    
    DocumentRoot "E:\workspace\php\weixin_backend\wxadm"
    <Directory "E:\workspace\php\weixin_backend\wxadm">
        # AllowOverride All      # Deprecated
        # Order Allow,Deny       # Deprecated
        # Allow from all         # Deprecated

        # --New way of doing it
        
        #Options Indexes FollowSymLinks Includes ExecCGI
        Options All
        AllowOverride All
        Require all granted
        
        # 定义URL重定向规则,不是文件,则指向index.php,源自Php的Yaf框架
        # 也可以配置到网站源码的.htaccess文件中
        RewriteEngine On
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule .* index.php
    </Directory>
</VirtualHost>