apache 伪静态配置

1  现配置站点,

<VirtualHost *:80>

//访问名称

ServerName my.seo_demo.com

//项目地址

DocumentRoot "/Users/lijundong/Documents/SeoDemo"

//默认访问文件类型

DirectoryIndex index.html index.php

//错误日志存放地址

ErrorLog "/Users/lijundong/Documents/SeoDemo/logs"

 // 以上为网站主要配置,下面是配置访问权限和网站其他伪静态等配置

<Directory "/Users/lijundong/Documents/SeoDemo">

//配置开不开启,目录列表

Options -Indexes +FollowSymlinks

//配置启用Rewrite 

AllowOverride All

Require all granted

//设置都可以访问 ,Deny from all 都不可访问,还有order Allow Deny 设置访问 去中间差值

Allow from all

</Directory>

 </VirtualHost>

directory 中没有配置的项 apache都会以父级中的配置为主

2  cd /etc/hosts 中配置 127.0.0.1  xxx.xxx.cxx

3  开启apache Rewrite模块

LoadModule rewrite_module libexec/apache2/mod_rewrite.so  只要取消前面注视即可

4  然后配置.htaccess文件

    文件内容为: 

      <IfModule rewrite_module> //是否存在该配置 相当于if else语句

      RewriteEngine On //开启rewrite

      RewriteRule  (\d+)\.html$ index.php  //规则  此规则表示 然后以数字.html 都会访问index.php

      <IfModule>

5  语句中的配置也可以写在httpd.cong 的该站点配置的directory 中;

知识点来自:http://www.iqiyi.com/w_19rqqdt2ol.html#curid=1751966709_231918daaf7a28d60b4427cccb8c42de

posted @ 2016-08-11 20:41  jackylee92  阅读(241)  评论(0编辑  收藏  举报