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. js-利用插件qrcode.min.js,前端实时生成二维码

    qrcode.min.js <script type="text/javascript" src="js/jquery.min.js"></s ...

  2. Debian9安装MariaDB

    一:导入密钥并添加了存储库 sudo apt-get install software-properties-common dirmngr sudo apt-key adv --recv-keys - ...

  3. 洛谷——P1767 家族_NOI导刊2010普及(10)

    P1767 家族_NOI导刊2010普及(10) 题目描述 在一个与世隔绝的岛屿上,有一个有趣的现象:同一个家族的人家总是相邻的(这里的相邻是指东南西北四个方向),不同的家族之间总会有河流或是山丘隔绝 ...

  4. ML | SVM

    What's xxx An SVM model is a representation of the examples as points in space, mapped so that the e ...

  5. Play框架的用户验证。

    最近刚刚参与一个基于Play框架的管理平台的升级工作,其中涉及到了用户的验证工作.第一次接触play框架,直接看已有代码,有点晕.因此,自己实现了一个简单的用户验证功能. 首先,新建一个User类,包 ...

  6. [Android] 环境配置之Android Studio开发NDK

    分类:Android环境搭建 (14351)  (20) ========================================================作者:qiujuer博客:bl ...

  7. C#中的抽象类和子类

    namespace FreeDlder { // 抽象类 public abstract class Dld { protected Form1 mainGui; protected String i ...

  8. SolidEdge 打开工程图提示图纸已过期怎么办

    如下图所示,打开工程图时提示图纸已过期   点击工具-图纸视图跟踪器,按提示打开过期的装配体文件   更新这个装配体文件   然后切换到刚才提示过期的工程图文件,点击更新视图,下次再打开的时候就不会提 ...

  9. 自己写的通过ADO操作mysql数据库

    #include <iostream> #include <windows.h> #include <atlstr.h> #import "c:\Prog ...

  10. python正则中的贪婪与非贪婪

    当重复一个正则表达式时,如用 a*,操作结果是尽可能多地匹配模式.当你试着匹配一对对称的定界符,如 HTML 标志中的尖括号.匹配单个 HTML 标志的模式不能正常工作,因为 .* 的本质是“贪婪”的 ...