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. 微信小程序踩坑之一[wx.request]请求模式

    最近在做小程序时,使用wx.request()方法请求时, 当使传输string类型时,一定要声明method请求模式为post,否则会一直报错,而不声明时默认为get, 已填坑 =,= wx.req ...

  2. (1)hello world

    操作系统安装SDK     https://www.microsoft.com/net/download/windows 选择对应的操作系统 wget -q https://packages.micr ...

  3. SSL/TLS协议

    今天闲着给自己的网站申请了一个免费证书,顺便复习下SSL/TLS协议    (https 就是在http+ssl协议) SSL介绍: 安全套接字(Secure Socket Layer,SSL)协议是 ...

  4. 跳转到指定页面popToViewController用法

    有人问popToViewController的用法 就写了下了 希望能帮到有需要的人 [self.navigationController popToViewController:[self.navi ...

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

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

  6. phonegap工程中修改app的名字

    针对phonegap比较高的版本,我的是6.4.0. 在phonegap工程中,当添加了iOS和android平台或多个平台后,工程进行了开发,然后觉得app的名字想修改一下(比如在手机上显示的app ...

  7. binary-tree-maximum-path-sum——二叉树任意一条路径上的最大值

    Given a binary tree, find the maximum path sum. The path may start and end at any node in the tree. ...

  8. mysql freeing items 状态

    http://blog.sina.com.cn/s/blog_6128a8f00100wsdd.html数据库出现大量的freeing items状态 表更新慢 而且大量锁表查看mysql官方free ...

  9. diff patch

    http://rails-deployment.group.iteye.com/group/wiki/1318-diff-and-patch-10-minutes-guide 情景一:你正尝试从代码编 ...

  10. linux下nginx+php+mysql 自助环境搭建

    ++++++++++++++++++++++++++++++++++++++++++++++linux下nginx+php+mysql环境搭建+++++++++++++++++++++++++++++ ...