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)
'2' (length=1)

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-13
  • 2022-12-23
  • 2022-12-23
  • 2018-12-11
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-19
  • 2021-10-30
  • 2021-05-30
  • 2022-12-23
  • 2021-05-16
相关资源
相似解决方案