Mar*_*tin 1 regex apache .htaccess mod-rewrite url-rewriting
我有像/?test我想重写的网址
/page.php?page=test
我试过这样但是由于某种原因它不起作用.
RewriteRule ^\?([a-z0-9\-\+]{3,20})/?$ /page.php?page=$1 [NC,QSA]
我究竟做错了什么?
查询字符串只能使用RewriteCond指令进行测试.该RewriteRule模式仅针对URL路径进行测试(在.htaccess文件中没有每个目录前缀的URL路径).
试试这个:
RewriteCond %{QUERY_STRING} ^[a-z0-9-+]{3,20}$ [NC]
RewriteRule ^$ /page.php?page=%0 [QSA]