RewriteRule中的正则表达式需要考虑是否要加上^(匹配字符串开头)
2007-09-28 21:05
537 查看
RewriteRule中的正则表达式需要考虑是否要加上^(匹配字符串开头)
[例一]
RewriteRule /news/(/d+)/.html /news/.php/?id=$1 [N,L]不仅匹配
http://localhost/news/1.html 也会匹配
http://localhost/test/news/1.html 因此应当加上^
RewriteRule ^/news/(/d+)/.html /news/.php/?id=$1 [N,L]
这样就不会匹配
http://localhost/test/news/1.html
[例二]
RewriteRule /blog/user/(.+)/.html$ /blog/user/blog_show.jsp?userid=$1 [PT]不仅匹配
http;//localhost/blog/user/1.html
也匹配
http;//localhost/test/blog/user/1.html
因此应当加上^
RewriteRule ^/blog/user/(.+)/.html$ /blog/user/blog_show.jsp?userid=$1 [PT]
这样就不会匹配
http://localhost/test/news/1.html
[apache关键词]
apache[rewrite模块关键词]
httxt2dbmmod_rewrite
ornext
RewriteBase
RewriteCond
RewriteEngine
RewriteLog
RewriteLogLevel
RewriteMap
RewriteRule
[rewrite模块常见用途]
改变查询参数的设定位置[rewrite模块标记]
RewriteLog, 设置重写引擎日志的文件名RewriteRule, 设置重写规则
[rewrite模块常见问题]
RewriteRule中的正则表达式需要考虑是否要加上^(匹配字符串开头)相关文章推荐
- Apache - mod_rewrite - RewriteRule中的正则表达式需要考虑是否要对.转义(匹配任意字符还是仅匹配.
- php正则表达式匹配用户名规则:由字母开头的6-16位字母和数字组成的字符串
- 正则表达式 匹配以特定字符串开头 到任意第一个字符中间的空格
- 用正则表达式来判断是否有需要的字符串
- PHP正则表达式匹配自定义开头结尾之前字符串
- python使用正则表达式匹配字符串开头并打印示例
- 【java基础之代码】【正则表达式匹配字符串检测输入的是否为手机号码】
- Apache - 模块 - mod_rewrite - RewriteRule - 匹配任意字符串时,可以借助正则表达式的灵活特性
- C#之判断字符串是否以187开头 By -->正则表达式!...
- C#之判断字符串是否以187开头 By -->正则表达式!...
- 正则表达式:检查一个句子或者字符串是否以大写字母开头,以句号结尾.
- Js 正则表达式匹配字符串中是否含有中文
- python 正则表达式:匹配字符串开头并打印
- 用sed命令进行正则表达式匹配字符串,如何检验匹配是否成功?
- 详解Ruby中正则表达式对字符串的匹配和替换操作
- 使用正则表达式匹配特殊字符串,例一
- 正则表达式匹配一行开头
- 正则表达式 表示 非指定字符串开头的正则
- 正则表达式匹配字符串match+pattern
- 字符串正则表达式匹配