1、404跳转:

<IfModule dir_module>
    DirectoryIndex index.php index.html /error.php
</IfModule>

#/error.php是apache的根目录

2、apache配置段:

(1)目录权限限制

Alias /dir/ "/var/www/html"    #虚拟目录即访问dir的时候跳转到/var/www/html目录

<Directory /var/www/html/>    #目录访问权限 ,或者<Directory /var/*/html/> *表示通配符

  Options Indexes FollowSymLinks       #允许目录索引,支持软连接

  Order Allow,Deny        #先允许后拒绝

  Deny from 192.168.1.111  #拒绝访问该目录

  Allow from all   #允许访问该目录

  AllowOverride All  #开启.htaccess(默认是开启的),把目录配置权限交给用户,上面的配置内容不用写

</Directory>

(2)文件权限限制(Files可以嵌套到Directory配置段里,即限制某个目录下的某个文件不能访问)

<Files "demo.html">

  Order Deny,Allow

  Deny from all

</Files>

<FilesMatch \.(gif|jpe?g|png)$>  #正则模式

  Order Deny,Allow

  Deny from all

</FilesMatch>

(3)以pri开头的网络地址

<Location '/pri'>

  ......

</Location>

3、.htaccess(不建议使用,比较浪费apache资源)

Options Indexs FollowSymLinks  #允许目录索引,支持软连接

Order Allow,Deny                      #先允许后拒绝

Allow from all                            #允许所有访问

4、虚拟主机的配置(重点):

#

# 管理员邮箱

# 网站根目录

#  Directory限制该目录的权限

# 绑定域名

# 绑定其他域名

# 错误日志

# 正常访问日志

#

<VirtualHost *:80>

  ServerAdmin admin@php.com

  DocumentRoot "/home/php5"

  <Directory "/home/php5">

    Options Indexes FollowSymLinks

    AllowOverride All

    Order Allow,Deny

    Allow from all

  </Directory>

  ServerName www.php.com

  ServerAlias cs.php.com

  ErrorLog "/home/php5/logs/error_log"

  CustomLog "/home/php5/logs/access_log"

</VirtualHost>

# 禁止所有以logs开头的文件都禁止访问

<Location "/logs">

  Order Deny,Allow

  Deny from all

</Location>

apache配置文件详解及虚拟主机的搭建的更多相关文章

  1. (原创)LAMP搭建之二:apache配置文件详解(中英文对照版)

    LAMP搭建之二:apache配置文件详解(中英文对照版) # This is the main Apache server configuration file. It contains the # ...

  2. ubuntu apache2配置详解(含虚拟主机配置方法)

    ubuntu apache2配置详解(含虚拟主机配置方法) 在Windows下,Apache的配置文件通常只有一个,就是httpd.conf.但我在Ubuntu Linux上用apt-get inst ...

  3. apache配置文件详解与优化

    apache配置文件详解与优化 一.总结 一句话总结:结合apache配置文件中的英文说明和配置详解一起看 1.apache模块配置用的什么标签? IfModule 例如: <IfModule ...

  4. Apache配置文件详解

    1.1 ServerRoot 配置 [ServerRoot "" 主要用于指定Apache的安装路径,此选项参数值在安装Apache时系统会自动把Apache的路径写入.Windo ...

  5. apache配置文件详解(中英文对照版)

    # This is the main Apache server configuration file. It contains the # configuration directives that ...

  6. Apache 配置文件详解

    0x01 禁止目录列表访问 () 备份httpd.conf配置文件,修改内容: <Directory "/web"> Options FollowSymLinks Al ...

  7. linux下的apache配置文件详解

    .Apache的配置由httpd.conf文件配置,因此下面的配置指令都是在httpd.conf文件中修改. 站点的配置(基本配置) (1) 基本配置: ServerRoot "/mnt/s ...

  8. Apache服务的主要目录和配置文件详解

    Apache服务的主要目录和配置文件详解 2014-01-14 19:05:14 标签:httpd配置文件详解 apache配置文件 httpd配置文件 apache文件目录 原创作品,允许转载,转载 ...

  9. ubuntu nginx 安装以及配置文件详解

    1.到nginx官网下载源码包.最好下载稳定版本,nginx官网http://www.nginx.org/ 2.安装nginx依赖包运行命令: sudo apt-get install libssl- ...

随机推荐

  1. IOS-<input>表单元素只能读,设置readonly时光标仍然可见的解决办

    在HTML中,如果把一个<input>的readonly属性设置为"readonly",表示这个表单元素不能编辑. 但是,鼠标点击之后,这个表单元素还是有光标存在的. ...

  2. commons-lang3工具类学习--------ObjectUtils

    Object工具类 allNotNull(Object... values) 检查所有元素是否为空,返回一个boolean 如果有一个元素为空返回false,所有元素不为空或元素为empty返回tru ...

  3. jsonp _____跨域请求实现

    请求如下: $.ajax({ type: "GET", async:false, url: "http://127.0.0.1:8080/Cross-site-reque ...

  4. Ubuntu 16.04安装MongoDB的GUI工具RoboMongo

    一.下载: https://robomongo.org/download 离线版本:(链接: https://pan.baidu.com/s/1mirFi56 密码: y3t2) 二.安装: -lin ...

  5. SpringBoot中@EnableAutoConfiguration注解用法收集

    参考: http://blog.csdn.net/xiaoyu411502/article/details/52770723 https://docs.spring.io/spring-boot/do ...

  6. 从零开始开发iPhone,教你如何在真机调试iPhone应用程序

    对于真机调试,首先要在苹果网站上注册APP ID,以及购买iPhone Develop Program(iDP) 开发者授权,99美元.然后要创建证书请求CSR,创建步骤如下:设置OCSP和CRL为关 ...

  7. Zen of Python(Python的19条哲学)

    The Zen of Python Beautiful is better than ugly. Explicit is better than implicit. Simple is better ...

  8. PC和手机怎么实现绝对居中?

    示例1(懒人之家): http://www.51xuediannao.com/js/nav/360buy_nav.html 示例2(google官方):

  9. iOS UI08_tableView省市区字典数组

    北京 1 北京市 1 西城区 1 东城区 2 崇文区 3 宣武区 4 朝阳区 5 丰台区 6 石景山区 7 海淀区 8 门头沟区 9 房山区 10 通州区 11 顺义区 12 昌平区 13 大兴区 1 ...

  10. vue2.0 自定义 生成二维码(QRCode)组件

    1.自定义 生成二维码组件 QRCode.vue <!-- 生成二维码 组件 --> <template> <canvas class="qrcode-canv ...