开发者

Catching multiple levels of 'virtual' directories with htaccess

Currently I have the following rules...

RewriteRule ^([^/]+)/([^/]*)(.htm)?$ index.php?filter=$1&page=$2 [L,QSA]
RewriteRule ^([^/]+)/$ index.php?filter=$1 [L,QSA]

Which basically catch anything in /dirname/page.htm

Now there exists the chance that the script will have to intercept a variable level of paths, such as /dirname/twodirname/threedirname/page.htm

Is there a way of doing this and handling the result in PHP with one rule 开发者_C百科rather than a mess of them in htaccess (and the multiple _GET variables generated)?


You can handle the URL in PHP no problem. I had the same question a few weeks ago, check out the accepted answer.

Don't let the rule be too general, though. Any kind of static resources should still be accessed directly, passing them through PHP is expensive.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜