Heim >Backend-Entwicklung >PHP-Tutorial >100分··求isapi_rewrite重写规则
htaccess伪静态规则
格式:请求地址 → 目标地址
1,/abc123.htm → /index.php?page=abc123
2,/a/xxxx → /a/index.php?id=xxxx
3,/b/xxxx → /b/index.php?id=xxxx
4,/xxxx.html?id=123&ty=aaa → /index.php?page=xxxx&id=123&ty=aaa
求大神编写isapi_rewrite跳转规则,实现以上跳转需求。
急``急````急``````
RewriteRule ^(.*)/abc(.*).html$ $1/index\.php?page=abc$2RewriteRule ^(.*)/a/(.*)$ $1/a/index\.php?id=$2RewriteRule ^(.*)/b/(.*)$ $1/b/index\.php?id=$2RewriteRule ^(.*)/(.*).html?id=(.*)&ty=(.*)$ $1/index\.php?page=$2&id=$3&ty=$4
RewriteRule ^(.*)/abc(.*).html$ $1/index\.php?page=abc$2RewriteRule ^(.*)/a/(.*)$ $1/a/index\.php?id=$2RewriteRule ^(.*)/b/(.*)$ $1/b/index\.php?id=$2RewriteRule ^(.*)/(.*).html?id=(.*)&ty=(.*)$ $1/index\.php?page=$2&id=$3&ty=$4
RewriteRule ^(.*)/abc(.*).html$ $1/index\.php?page=abc$2RewriteRule ^(.*)/a/(.*)$ $1/a/index\.php?id=$2RewriteRule ^(.*)/b/(.*)$ $1/b/index\.php?id=$2RewriteRule ^(.*)/(.*).html?id=(.*)&ty=(.*)$ $1/index\.php?page=$2&id=$3&ty=$4
RewriteRule ^(.*)/abc(.*).html$ $1/index\.php?page=abc$2RewriteRule ^(.*)/a/(.*)$ $1/a/index\.php?id=$2RewriteRule ^(.*)/b/(.*)$ $1/b/index\.php?id=$2RewriteRule ^(.*)/(.*).html?id=(.*)&ty=(.*)$ $1/index\.php?page=$2&id=$3&ty=$4
其实就是想把/xxxx.html?id=123&ty=aaa这个请求中的" xxxx.html?"部分换成"index.php?mod=xxxx&"
其实就是想把/xxxx.html?id=123&ty=aaa这个请求中的" xxxx.html?"部分换成"index.php?mod=xxxx&"
其实就是想把/xxxx.html?id=123&ty=aaa这个请求中的" xxxx.html?"部分换成"index.php?mod=xxxx&"
问题依然存在,还有人能指点一下不
RewriteRule ^(.*)/(.*).html?(.*)$ $1/index\.php?page=$2
RewriteRule ^(.*)/(.*).html?(.*)$ $1/index\.php?page=xxxx $2
RewriteRule ^(.*)/xxx.html?(.*)$ $1/index\.php?page=xxxx $2
RewriteRule ^(.*)/xxx.html?(.*)$ $1/index\.php\?page=xxxx $2
RewriteRule ^(.*).html\?(.*)$ index.php?mod=$1&$2
感谢楼上两位,我自己找到答案了
/xxxx.html?id=123&ty=aaa匹配规则如下
RewriteCond %{QUERY_STRING} ^id=(.+)&ty=(.+)$
RewriteRule xxxx\.html$ index\.php\?page=xxxx&id=%1&ty=%2 [L]
这个规则就可以匹配html后面有参数的url。