lilzz
lilzz

Reputation: 5413

.htaccess redirect. Prioritize one rule over another

I have two rules on .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]

I want rule number 1 to have priority over rule number 2, but right now number 2 is always in effect and rule number 1 is missing.

Upvotes: 0

Views: 218

Answers (1)

bluesmoon
bluesmoon

Reputation: 4320

Change the flags for the first rule from [QSA] to [QSA,L]

That will make sure that Rule processing will stop when Rule 1 matches. You may also want to put in a RewriteCond for Rule 1 to make sure that it doesn't catch everything.

Upvotes: 1

Related Questions