Htaccess with multiple parameters

.htaccessrewrite

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

Here is my .htaccess. However only the first RewriteRule works. If I comment out other rules, the others left work fine, but they don't work together. What I want is the clean URL with multiple parameters.

I don't have any clue of this problem. I Googled a lot and all the information I've found says the same as my code.

Best Answer

You need to chain your RewriteRules using the C flag, as explained on the ServerFault page Everything You Ever Wanted to Know about Mod_Rewrite Rules but Were Afraid to Ask?

In your case, this would do:

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