apache rewrite 规则示例
apache rewrite 规则示例
RewriteRule ^itnews/([-]{})/([-]{})([-]{})/([^/_]*)_([-]+).html$ http:
RewriteCond %{REQUEST_FILENAME} ^http:
RewriteCond %{DOCUMENT_ROOT}% !- RewriteRule ^http:
RewriteCond %{REQUEST_FILENAME} ^http:
RewriteCond %{DOCUMENT_ROOT}% !- RewriteRule ^http:
RewriteCond %{REQUEST_FILENAME} ^http:
RewriteCond %{DOCUMENT_ROOT}% !- RewriteRule ^http:
实现功能把 http://www.test.com/itnews/2013/0101/phone_12354.html 跳转到http://www.test.com/news/201301/(33|11|12)_12354.html
一些问题:
1.flags [
2.flags [chain|C]跳转后,RewriteCond 中
RewriteCond %{REQUEST_FILENAME} !-^news/([-]{})/12_([-]+).html$ http:
RewriteCond %{REQUEST_FILENAME} ^http:
RewriteCond %{DOCUMENT_ROOT}% !-^http:
3.
^content-([-]+)-([-]+)-([-]+).html index.php?m=content&c=index&a=show&catid=$&id=$&page=$^content-([-]+)-([-]+)-([-]+).html http:
由于apache配置环境或者相对路径不同。
(RewriteCond %{REQUEST_FILENAME} !- non-regex pattern
RewriteCond %{QUERY_STRING} ^a=(.*^test1.php$ http:
http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html
速查表:
RewirteRule 标记 | 含义 | 描述 |
R | Redirect | 发出一个HTTP重定向 |
F | Forbidden | 禁止对URL地址的存取 |
G | Gone | 标记URL地址不存在 |
P | Proxy | 将URL地址传递至mod_proxy |
L | Last | 停止处理接下来的规则 |
N | Next | 再次从第一个规则开始处理,但是使用当前重写后的URL地址 |
C | Chain | 将当前的规则和紧随其后的规则链接起来 |
T | Type | 强制执行指明的MIME类 |
NS | Nosubreq | 只在没有任何内部子请求执行时运用本规则 |
NC | Nocase | URL地址匹配对大小写敏感 |
QSA | Qsappend | 在新的URL地址后附加查询字符串部分,而不是替代 |
PT | Passthrough | 将重写后的URL地址传递给另一个Apache模块进行进一步处理 |
S | Skip | 忽略之后的规则 |
E | Env | 设置环境变量 |
评论暂时关闭