Mod rewrite url重写帮助
我正在使用url重写,就像Mod rewrite url重写帮助,mod-rewrite,Mod Rewrite,我正在使用url重写,就像 RewriteRule ^mobiles/(.*)$ /mobile_rating.php?alias=$1 [L,B] 这对我来说就像 /mobiles/nokia70 /mobile_rating.php?alias=nokia70 我需要像这样的零钱 /mobiles/nokia70 /mobile_rating.php?alias=nokia70&product=mobiles 我的意思是,像url中的手机一样,必须更改为product=m
RewriteRule ^mobiles/(.*)$ /mobile_rating.php?alias=$1 [L,B]
这对我来说就像
/mobiles/nokia70 /mobile_rating.php?alias=nokia70
我需要像这样的零钱
/mobiles/nokia70 /mobile_rating.php?alias=nokia70&product=mobiles
我的意思是,像url中的手机一样,必须更改为product=mobiles。我该如何做。任何提示如果您的意思是产品变量是从url的第一部分确定的,那么这将完成:
RewriteRule ^(.*)/(.*)$ /mobile_rating.php?alias=$2&product=$1 [L,B]
但是,我会将字符匹配从*
更改为不太通用的内容。上述内容将改写为/mobiles/nokia70/abc
至/mobile_rating.php?alias=abc&product=mobiles/nokia70
[^/]+
将匹配不包含正斜杠的字符串,或者如果您总是使用一组严格的字母/数字,请尝试匹配任何小写字母、数字或连字符的[a-z0-9-]+