Rainie999 发表于 2015-8-5 10:43:50

Apache 下更改 DocumentRoot 和新建虚拟目录

  Apache 安装后,默认的 DocumentRoot 是安装目录下的 htdocs 目录,编程时有很多不便,如需更改,打开安装目录 conf 子目录下的 httpd.conf 文件,修改 DocumentRoot 属性即可,如更改为:DocumentRoot “E:/My/DocRoot”。
  在 IIS 下,新建虚拟目录可通过可视化界面操作,在 Apache 中,新建虚拟目录通过修改 httpd.conf 文件实现。
  在 httpd.conf 的 alias_module 下增加一别名定义项,如:Alias “/onefly” “E:/My/Onefly” ,即可定义虚拟目录。

  更改以上设置后,必须重启 Apache 才能使设置生效。同时,要对相应目录作权限定义,否则会出现无权访问的错误提示。
  要对目录定义权限,可在 httpd.conf 文件中定义类似以下的代码:
  
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all

  =======================================================================
  自己机器上配置实例如下:



    #
    # Redirect: Allows you to tell clients about documents that used to
    # exist in your server's namespace, but do not anymore. The client
    # will make a new request for the document at its new location.
    # Example:
    # Redirect permanent /foo http://www.waydu.com/bar

    #
    # Alias: Maps web paths into filesystem paths and is used to
    # access content that does not live under the DocumentRoot.
    # Example:
    # Alias /webpath /full/filesystem/path
    ##################################################################
   Alias   /study   "D:/PHP/www/study"
      
            Options   Indexes   Includes   FollowSymLinks   MultiViews   IncludesNoExec   
            AllowOverride   None   
            Order   allow,deny   
            Allow   from   all   
      
    ##################################################################  
页: [1]
查看完整版本: Apache 下更改 DocumentRoot 和新建虚拟目录