关于apache配置虚拟主机
2015-12-10 11:32
543 查看
最近看了下Apache配置虚拟主机,主要有三个步骤
1、在Apache中的httpd.conf里面开启httpd.vhost模块,也就是把这个模块挂载在httpd.conf中
2、在httpd.vhost里面写入
3、在c盘系统盘里面找到host文件,把127.0.0.1a.com写入文件里面,重新启动Apache
关于第二代配置这里讲解下
1、在Apache中的httpd.conf里面开启httpd.vhost模块,也就是把这个模块挂载在httpd.conf中
2、在httpd.vhost里面写入
<VirtualHost*:80> DocumentRoot"E:/a" ServerNamea.com <Directory"E:/a"> #Options+indexes OrderAllow,Deny Allowfromall </Directory> </VirtualHost>
3、在c盘系统盘里面找到host文件,把127.0.0.1a.com写入文件里面,重新启动Apache
关于第二代配置这里讲解下
DocumentRoot"E:/a" ServerNamea.com 这两行必须,它说明了网站目录跟网站域名地址 而OrderAllowDeny则说明先看允许的,在看不允许的,下面的Allowfromall则允许全部,如果想禁止某个则可以使用Deny192.168.1.100类似地址 还可以在后面加入
RewriteEngineOn RewriteRule([a-z]+)/([a-z]+)/(\d+)\.html$showNew.php?ctr=$1&fn=$2&id=$3 DirectoryIndexa.txt ErrorDocument404'target='_blank'>http://a.com/test.html[/code]
第一行说明开启重写模块
第二行是重写的规则重写的规则是使用正则表达式RewriteRule([a-z]+)/([a-z]+)/(\d+)\.html$showNew.php?ctr=$1&fn=$2&id=$3 上一行的意思是如果浏览器碰到([a-z]+)/([a-z]+)/(\d+)\.html$这个规则的路径如Index/login/2.html 则让Apache去showNew.php?ctr=Index&fn=login&id=2的动态文件,也就是伪静态技术 这里的正则表达式使用了子表达式([a-z]+),捕获,方向引用($1代表第一个子表达式)DirectoryIndexa.txt这一行说明如果访问a.com这个域名,这直接指向a.txt这个文件ErrorDocument404http://a.com/test.html这里指明了如果出现404则跳转到test.html这里需要写全域名,即 http://a.com/test.html如果是/test.html则不能成功跳转指向。
相关文章推荐
- org.apache.harmony.xml.ExpatParser$ParseException: At line 1, column 0: unknown encoding
- org.apache.lucene.queryParser.ParseException: Encountered "<EOF>" at line 1, column 0.
- xampp apache port 更改
- Apache Commons工具集简介
- centOS下自带安装了apache和php,如何配置呢 ?
- Apache 安装步骤
- Apache CXF 和 Spring 开发RESTful Web Service 2
- apache AH01630: client denied by server configura
- LAMP 2.7 Apache通过rewrite限制某个目录
- LAMP 2.6 Apache 禁止指定user_agent
- LAMP 2.5 Apache禁止解析php
- windows下安装配置apache、mysql、php
- solr服务器报错:org.apache.solr.common.SolrException: Could not find necessary SLF4j logging jars
- ubuntu下安装Apache+PHP+Mysql
- Apache Kafka监控之Kafka Web Console
- Apache Kafka监控之KafkaOffsetMonitor
- Apache Kafka-0.8.1.1源码编译
- apache 实现备份服务器-热备份(hot standby)
- How To Install Apache Kafka on Ubuntu 14.04
- ubuntu apache 执行 cgi