RewriteRule 不会去匹配 ? 后面的字符串,需要用RewriteCond来匹配
把 /abc?id=123 => /def.php?id=123 的写法:
RewriteEngine on
RewriteCond %{QUERY_STRING} ^id=(.+)$
RewriteRule ^/abc$ /def.php?sid=%1 [L]
#启用重写后,避免静态资源访问出错
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/css
RewriteCond %{REQUEST_URI} !^/js
RewriteCond %{REQUEST_URI} !^/images
RewriteCond %{REQUEST_URI} !^.*(.css|.js|.gif|.png|.jpg|.jpeg|.xml)
#解决重写后接不到问号后面的参数
RewriteCond %{QUERY_STRING} ^(.*)$
#RewriteRule ^(w+)-(w+).html index.php?c=$1&a=$2%1 [L,QSA]
#把URL中的index.php省略掉
RewriteRule ^/(.*) /index.php?$1 [L,QSA]
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^userd-([0-9]+)-boardlist.html$ pyquan.php?action=boardlist&uid=$1&%1 [L]http://localhost:8084/userd-1-boardlist.html?page=2
array (size=3) ‘action‘ =>‘boardlist‘(length=9)
‘uid‘ =>‘1‘(length=1)
‘page‘ =>‘2‘(length=1)
原文:http://www.cnblogs.com/as3lib/p/6854344.html
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!