伪静态

一.开启重写模块
二.找到搜索到httpd.conf:AllowOverride 
方法一:直接在httpd.conf文件下改 (不推荐,这样导致服务器上的所有网站都开启了重写,每个网站访问时都会扫描.htaccess文件)
<Directory />
   AllowOverride none (改成 AllowOverride all)
   Require all granted
</Directory>


方法二:直接添加在httpd.conf文件底部
<Directory "D:/wamp/www"(网站路径)>
   Options FollowSymLinks
   AllowOverride all
   Order deny,allow
</Directory>


方法三:直接在虚拟主机里面添加目录权限(httpd-vhosts.conf或者httpd.conf)
<VirtualHost *:80>
   DocumentRoot "D:/wamp/www/test"
   ServerName test.com
   ServerAlias test.com
   <Directory "D:/wamp/www"(网站路径)>
   Options FollowSymLinks
   AllowOverride all
   Order deny,allow
</Directory>
</VirtualHost>


Options指令-------目录的访问特性
option  none    禁止对目录的所有操作
option all      允许对目录的所有操作,ALL---所有操作
option ExecCGI    对该目录,可以执行cgi脚本
option Indexes    允许访问该目录(而该目录没有index.html)时,返回目录下的文件列表                        
option FollowSymLinks       只允许对目录的FollowSymLinks操作


AllowOverride指令
None    不读取.htaccess
all    all----允许.htaccess所有指令,缺省是all
Limit    .htaccess函盖具体限定的主机(allow,deny)
AuthConfig    .htaccess函盖跟认证有关指令(AuthType,AuthName) 


Order 指令
为指定排序deny或者是allow,用','隔开
Deny from XXX
Allow from XXXX
参数3可以是IP(可以使某个范围或者是特定一个),域名,all
Allow from 10.1.2.3
Allow from 192.168.1.104 192.168.1.205
Allow from apache.org


三.在根目录下添加.htaccess文件
内容形如:
RewriteEngine on
# 统一网址,去掉www。如果你想保留www,自己在第二行添加
# RewriteCond的'%'是后向引用 [NC]代表不区分大小写
# RewriteRule的'$'是后向引用 [L,R=301] L表明当前规则是最后一条规则,停止分析以后规则的重写 R重定向(301重定向是永久的重定向/302重定向是暂时的重定向)
#RewriteCond ^%{HTTP_HOST} ^test.com [NC]
RewriteCond %{HTTP_HOST} ^test.com [NC]
RewriteRule ^(.*)$ http://www.test.com/$1 [L,R=301]
#RewriteCond %{HTTP_HOST} test.com [NC]
#RewriteRule (.*) http://www.baidu.com/$1 [R=301,L]
RewriteRule ^index.html$ index.php 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值