mod_rewrite添加另一个规则

时间:2012-05-06 16:59:47

标签: php mod-rewrite

RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|robots\.txt)
RewriteRule ^(.*)$ index.php?p=$1 [L]

我使用它将所有路由转发到index.php,如果我要重写以下内容:

http://localhost/folder/method/value

那就是

http://localhost/folder/method/?f=value

如何让它发挥作用?

1 个答案:

答案 0 :(得分:0)

请参阅mod rewrite tage wiki和示例6。

对于您的具体情况,您可以预先

这样的规则
RewriteRule ^(\w+)/(\w+)/(\w+)$  $1/$2/?f=$3 [L]

另请参阅Serverfault: Everything You Ever Wanted to Know about Mod_Rewrite Rules but Were Afraid to Ask?以了解规则排序。

相关问题