+ -
当前位置:首页 → 问答吧 → apache rewrite 问题请教

apache rewrite 问题请教

时间:2010-08-02

来源:互联网

http://xxx.com/lls/  匹配到  list.php?list=lls

怎么匹配啊


  
我用^(\w+)$    list\.php\?list=$1  [QSA,L]  这样写可以 可以 把 http://xxx.com/lls  转到 http://xxx.com/list.php?list=lls
但是我的连接后面都有/ 所以我想把这个/ 也带上  (连接是这样的  http://xxx.com/lls/) 加上/就不行了


然后我用 ^(lls)\/$  list\.php\?list=$1  可以匹配页面   但是把我页面里的   都给匹配成 这样了 图片和样式文件都不能正常显示了  所以我想排除 themes 和 css  这样的字符(图片 css都给我匹配到  lls 文件夹下了)

其实我的规则是

http://xxx.com/lls/                  匹配到  list.php?list=lls                             最后有斜线的匹配
http://xxx.com/lls/aas.html    匹配到  list.php?list=aas                           最后有斜线的后面还有带***.html的匹配
http://xxx.com/aaa.html        匹配到  new.php?new=aaa                       最后有***.html的前面是域名的匹配(非子目录形式的)
上面的都排除 http://xxx.com/aaa-123.html  和 http://xxx.com/bbb-456.html 这样的连接


各位大虾帮帮忙!

作者: piaohh   发布时间: 2010-08-02

各位兄弟姐妹  给个意见

作者: piaohh   发布时间: 2010-08-02

http://xxx.com/lls/                  匹配到  list.php?list=lls                             最后有斜线的匹配
http://xxx.com/lls/aas.html    匹配到  list.php?list=aas                           最后有斜线的后面还有带***.html的匹配
http://xxx.com/aaa.html        匹配到  new.php?new=aaa                       最后有***.html的前面是域名的匹配(非子目录形式的)
上面的都排除 http://xxx.com/aaa-123.html  和 http://xxx.com/bbb-456.html 这样的连接


可以试试RewriteCond 利用 OR 把这些规则批配出来...
例如
RewriteCond %{SCRIPT_FILENAME} ^\/IIs\/$
RewriteRule ^/(IIs)/ http://xxx.com/list.php?list=IIs

用RewriteCond 就可以设定你要的条件,
其他的你自己研究看看吧..

作者: apile   发布时间: 2010-08-02

热门下载

更多