Gustavo Porto
Gustavo Porto

Reputation: 224

.htaccess with 2 rewriterule

I have 2 diff strings:

index.php?abrir=$1&id=$2 index.php?abrir=$1&livro=$2

id= and livro= so I'm trying using this:

RewriteRule ^([a-zA-Z0-9_-]+)/?$ index.php?abrir=$1
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/?$ index.php?abrir=$1&id=$2
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/?$ index.php?abrir=$1&id=$2&pagina=$3

RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/?$ index.php?abrir=$1&livro=$2
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/?$ index.php?abrir=$1&livro=$2&pagina=$3

But only the first work... How I can resolve this? Thanks!

Upvotes: 0

Views: 143

Answers (1)

Jan-Henk
Jan-Henk

Reputation: 4874

The matching patterns in your rewrite rules for abrir=.. and livro=.. are identical. The first rewrite rule in a .htaccess file that matches for the current request is used. So if you have two identical rewrite rules only the one that occurs first in your .htaccess file will work.

Upvotes: 2

Related Questions