这是我想做的:
/gestion/aa/ => /gestion/aa.php
/gestion/bb/ => /gestion/bb.php
/gestion/a/b/ => /gestion/a/b.php
/gestion/a/b/c/ => /gestion/a/b/c.php
/cmd/aa/ => /cmd/aa.php
/cmd/bb/ => /cmd/bb.php
/cmd/a/b/ => /cmd/a/b.php
/cmd/a/b/c/ => /cmd/a/b/c.php
/json/aa/ => /json/aa.php
/json/bb/ => /json/bb.php
/json/a/b/ => /json/a/b.php
/json/a/b/c/ => /json/a/b/c.php
这让我想到了这个简单的正则表达式:
^/(gestion|cmd|json)/(([^/]+/)*)$ /$1/$2.php [QSA,L]
问题是它$2
总是在内部/
,所以结果是:
/json/aa/ => /json/aa/.php
/json/bb/ => /json/bb/.php
/json/a/b/ => /json/a/b/.php
/json/a/b/c/ => /json/a/b/c/.php
知道如何获得正确的正则表达式吗?