apache在window上建虚拟目录

来源:互联网 发布:万达电商 淘宝的 编辑:程序博客网 时间:2024/09/21 09:04

你想通过www.aabbccdd.com这样的形式来代替127.0.0.1吗?想通用aa.aabbccdd.com方式来建立二级域名吗?

下面就说一下具体的实现:

一是打开apache的配置文件httpd.conf 找到#Include conf/extra/httpd-vhosts.conf  把前面的#号去掉.

二是在:C:\WINDOWS\system32\drivers\etc 下的hosts文件最后添加一行:127.0.0.1 www.aabbccdd.com   后面那个二级目录同理.

三是:在httpd-vhosts.conf 这个文件里添加以下代码:

<VirtualHost *:80>
DocumentRoot "D:\WWW\website1\wwwroot"
ServerName demo.xxx.com
ServerAlias www.xxx.com #这里是别名,就是绑定多个域名
<Directory "D:\WWW\website1\wwwroot"> 
  Options FollowSymLinks IncludesNOEXEC Indexes
  DirectoryIndex index.htm index.html index.php
  AllowOverride Options FileInfo
  Order Deny,Allow
  Allow from all
</Directory>
LimitRequestLine 90940
LimitRequestFieldSize 90940
</VirtualHost>

四:重启apache,并收工.


apache2.4及以后的配置方式:

    <VirtualHost *:80>       ServerName www.demo.com       DocumentRoot "/home/www/sites/www"       DirectoryIndex index.html index.php             <Directory "/home/www/sites/www">        Options -Indexes +FollowSymlinks        AllowOverride All        Require all granted       </Directory>            </VirtualHost>  


原创粉丝点击