带有多个参数的htaccess

RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !\.php$ RewriteRule ^(.*)/(.*)/(.*)$ $1.php?Action=$2&id=$3 RewriteRule ^(.*)/(.*)$ $1.php?Action=$2 RewriteRule ^(.*)$ $1.php 

这是我的.htaccess 。 但只有第一个RewriteRule作品。 如果我评论其他规则,其他人就会很好地工作,但是他们不能一起工作。 我想要的是具有多个参数的干净的URL。

我没有任何关于这个问题的线索。 我GOOGLE了很多,我发现的所有信息都和我的代码一样。

您需要使用C标志来链接您的RewriteRules,正如ServerFault页面上所解释的, 您曾经想知道的关于Mod_Rewrite规则的所有内容,但是却不敢问?

在你的情况下,这将做到:

 RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !\.php$ RewriteRule ^(.*)/(.*)/(.*)$ $1.php?Action=$2&id=$3 [C] RewriteRule ^(.*)/(.*)$ $1.php?Action=$2 [C] RewriteRule ^(.*)$ $1.php 
 Options -MultiViews RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !\.php$ RewriteRule ^(.*)/(.*)/(.*)$ /api/$1.php?Action=$2&id=$3 [L] RewriteRule ^(.*)/(.*)$ /api/$1.php?Action=$2 [L] 

随着[L]国旗,我的htaccess开始工作正常。