.htaccess重定向。优先考虑一个规则而不是另一个规则

时间:2011-08-11 05:25:11

标签: .htaccess

我对.htaccess有两条规则

RewriteEngine On

1)RewriteRule ^simple_api/api/([a-zA-Z]+)  /simple_api/api.php?mode=$1 [QSA]

2)# Pass all requests not referring directly to files in the filesystem to index.php.
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !=/favicon.ico
  RewriteRule ^ index.php [L]

我希望规则编号1优先于规则编号2,但是现在编号2总是生效,规则编号1缺失。

1 个答案:

答案 0 :(得分:1)

将第一条规则的标记从[QSA]更改为[QSA,L]

这将确保规则1匹配时规则处理将停止。您可能还想为规则1添加RewriteCond以确保它不会捕获所有内容。

相关问题