apache建立虚拟目录_Apache建立虚拟目录几个例子

更新时间:2019-06-21    来源:apache    手机版     字体:

【www.bbyears.com--apache】

进入httpd.conf

在节点:

增加
Alias /php "E:/localhost/test"

其中 php是你想要访问的虚拟目录,E:/localhost/test为物理路径
因为Apache默认的不能访问的,所以要加一个配置。
我们就在后面接着加:

 代码如下


AllowOverride None
Options None
Order allow,deny
Allow from all

保存后,重新启动apache

例子

 代码如下

Alias /3DModelProject "E:/3DModelProject"


Options Indexes MultiViews
AllowOverride None
order allow,deny
Allow from all


Alias /109SharedFolder "E:/109SharedFolder"


Options Indexes MultiViews
AllowOverride None
order allow,deny
Allow from all

Alias /109ChemistrySharedFolder "E:/109ChemistrySharedFolder"


Options Indexes MultiViews
AllowOverride None
order allow,deny
Allow from all

设置默认页面

方法1 设置全局的:

 代码如下
    DirectoryIndex index.php index.php4 index.php3 index.cgi index.pl index.html index.htm index.shtml index.phtml default.php

方法2 针对某一目录可以这么设置:

 代码如下

Alias  /anstyla  "E:/anstyla/src/web"
 
          Options Indexes MultiViews 
          AllowOverride None 
          Order allow,deny 
          Allow from all 
          DirectoryIndex default.php

除了上面办法我们还有一个配置方法比较方便了,我们在apache配置文件httpd.conf找到

#Include conf/extra/httpd-vhosts.conf

我们把前面的#去掉

Include conf/extra/httpd-vhosts.conf

然后再把我们的网站目录直接写到这里httpd-vhosts.conf文件中。

 代码如下


    servername web-demo
    serveralias www.111cn.net 111cn.net
    documentroot "x:/www/htdocs"

最后重启动apache就可以了哦。

本文来源:http://www.bbyears.com/jiaocheng/55113.html

热门标签

更多>>

本类排行