PHP伪静态Rewrite设置之APACHE篇
2014-07-30 09:04
603 查看
一、Apache配置:
1、支持httpd.conf 配置
2、支持目录 .htaccess配置(一种"分布式配置"文件针对虚拟空间,空间商不让修改Apache配置文件)
启用Rewrite(httpd.conf)
(有时候Options Indexes FollowSymLinks会出问题,只需要配置Options all即可)
LoadModule rewrite_module modules/mod_rewrite.so
启用.htaccess
AllowOverride None 修改为:AllowOverride All
二、mod_rewrite 规则:
例如:
RewriteEngine on ->启动rewrite引擎 RewriteRule ^/test([0-9]*).html$ /test.php?id=$1 ->指访问test加任意字段.html都能跳转到test.php 正则匹配的字段存放在虚拟内存匹配$1
三、mod_rewrite规则修正符
1) R 强制外部重定向
2) F 禁用URL,返回403HTTP状态码。
3) G 强制URL为GONE,返回410HTTP状态码。
4) P 强制使用代理转发。
5) L 表明当前规则是最后一条规则,停止分析以后规则的重写。
6) N 重新从第一条规则开始运行重写过程。
7) C 与下一条规则关联
如果规则匹配则正常处理,以下修正符无效
8) T=MIME-type(force MIME type) 强制MIME类型
9) NS 只用于不是内部子请求
10) NC 不区分大小写
11) QSA 追加请求字符串
12) NE 不在输出转义特殊字符 \%3d$1 等价于 =$1
例如:
RewriteRule ^/new([0-9]*)/$ /new.php?id=$1 [R]
简单小范例:
RewriteEngine on RewriteRule ^/in(.*).html$ /index.php
您可能感兴趣的文章:
相关文章推荐
- PHP伪静态Rewrite设置之APACHE篇
- 关于PHP伪静态Rewrite设置
- 关于PHP伪静态Rewrite设置
- 为了实现伪静态 php、mysql、apache都需要做那些设置
- apache rewrite设置 禁止某个文件夹执行php文件
- PHP通过apache的mod_rewrite实现伪静态
- 设置apache服务器常用设置 301重定向 执行php权限 防盗链 伪静态等
- 关于PHP伪静态Rewrite设置
- PHP利用htaccess文件实现伪静态(Apache mod_rewrite)
- apache中配置PHP伪静态Rewrite重写
- PHP通过apache的mod_rewrite实现伪静态
- apache nginx 通过 rewrite 设置 禁止执行PHP程序
- Apache - mod_rewrite - 与PHP集成时不需要对$_GET额外处理
- apache Rewrite防盗链设置方法
- php 伪静态 (url rewrite mod_rewrite 重写) 本地APACHE支持urlrewrite 本地APACHE支持.htaccess
- Windows Vista下安装PHP5.2.8和Apache2.2.8,与Mysql 5.1.3,以及phpMyAdmin3.1.1安装设置过程总结
- Apache Rewrite 常用设置说明
- apache+php虚拟目录设置
- Apache、Tomcat、IIS(PHP、JSP、ASP)共存时的设置
- Apache URL Rewrite配置(php 伪静态)