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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值