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)
时间: 2024-10-24 13:07:55