阿帕奇mod-rewrite的.htaccess得到PARAMS [英] Apache mod rewrite .htaccess to get params
问题描述
我如何能赶上文件名后,婴儿车带扩展名状service.php /厂景
为前:
service.php / newview1
我要得到它像
service.php?查看= newview1
我怎样写mod-rewrite此
我试过像
重写规则^ services.php /?([A-ZA-Z _] +)$ /services.php?category=$1
其不匹配的service.php / newview1
在更换URI包含查询字符串,默认行为
重写规则是放弃现有的查询字符串,并更换
用新生成的一个。使用[QSA]标志导致查询
串要组合
块引用>您需要添加
[QSA]
标志,以结束当前行尝试添加此正则表达式:
([A-ZA-Z0-9 -_] +)
,因为这也符合任何整数和连字符也。重写规则^ services.php /?([A-ZA-Z0-9 -_] +)$ /services.php?category=$1 [QSA,L]
我也把
[L]
标志,以便它停止处理其他规则。How can i catch the prams after file name with extension like service.php/view1
for ex: service.php/newview1I want to get it like service.php?view=newview1
how do i write mod-rewrite for this
I tried like
RewriteRule ^services.php/?([a-zA-Z_]+)$ /services.php?category=$1
its not matching the service.php/newview1
解决方案When the replacement URI contains a query string, the default behavior of RewriteRule is to discard the existing query string, and replace it with the newly generated one. Using the [QSA] flag causes the query strings to be combined.
You need to add
[QSA]
flag to end of your current lineTry adding this regex:
([a-zA-Z0-9-_]+)
as this also matches any integers and hyphens also.RewriteRule ^services.php/?([a-zA-Z0-9-_]+)$ /services.php?category=$1 [QSA,L]
I also put the
[L]
flag so it stop processing further rules.这篇关于阿帕奇mod-rewrite的.htaccess得到PARAMS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!