请建议。
我有:
RewriteRule ^([0-9a-zA-Z-_]+)/?$ /index.php?page=$1 [NC,L]
RewriteRule ^([0-9a-zA-Z-_]+)/([0-9a-zA-Z-_]+)/?$ /index.php?page=$1&action=$2 [NC,L]
所以/blog/last
转换为/index.php?page=blog&action=last
我希望遵守这些规则并且我希望如下:
/search?p1=1 transform to /index.php?page=search&p1=1
/search?p1=1&unknown_name=unknown_value transform to /index.php?page=search&p1=1&unknown_name=unknown_value
等url ther名称和值中的任何参数计数
谢谢:)
答案 0 :(得分:0)
QSA
标记来保留现有的查询字符串。\w
代替[a-zA-Z0-9_]
试试这个:
RewriteRule ^([\w-]+)/?$ /index.php?page=$1 [QSA,L]
RewriteRule ^([\w-]+)/([\w-]+)/?$ /index.php?page=$1&action=$2 [QSA,L]