Rewrite:修订间差异

来自站长百科
跳转至: 导航、​ 搜索
第16行: 第16行:
==相关条目==
==相关条目==


[[伪静态]] [[网址规范化]] [[Apache]] [[Mod_rewrite]]
[[伪静态]] [[网址规范化]] [[Apache]] [[Mod_rewrite]] [[Htaccess]]


==参考资料==
==参考资料==

2009年9月5日 (六) 09:00的版本

Rewirte主要的功能就是实现URL的重写,它的正则表达式是基于Perl语言。可基于服务器级的(httpd.conf)和目录级的(.htaccess)两种方式。如果要想用到rewrite模块,必须先安装或加载rewrite模块。方法有两种一种是编译apache的时候就直接安装rewrite模块,别一种是编译apache时以DSO模式安装apache,然后再利用源码和apxs来安装rewrite模块。

基于服务器级的(httpd.conf)有两种方法,一种是在httpd.conf的全局下直接利用RewriteEngine on来打开rewrite功能;另一种是在局部里利用RewriteEngine on来打开rewrite功能,下面将会举例说明,需要注意的是,必须在每个virtualhost里用RewriteEngine on来打开rewrite功能。否则virtualhost里没有RewriteEngine on它里面的规则也不会生效。

基于目录级的(.htaccess),要注意一点那就是必须打开此目录的FollowSymLinks属性且在.htaccess里要声明RewriteEngine on。

Rewrite语法

常用Rwrite规则

IIS中使用Rewrite

Rewite作用

相关条目

伪静态 网址规范化 Apache Mod_rewrite Htaccess

参考资料

  1. http://doc.zzbaike.com/apache/2-2/rewrite/rewrite_guide.html
  2. http://doc.zzbaike.com/apache/2-2/mod/mod_rewrite.html