Reputation: 24384
I have two different php pages page.php and team.php. The Rule I've writtent for rewriting page.php is as follow
RewriteRule ^([^/]+)/([0-9]+)\/?$ /page.php?name=$1&id=$2
It will redirect the link example.com/privacy_policy/30
to example.com/page.php?name=privacy_policy&id=30
Now I want to write the Rule for team.php so that the link example.com/team/Zeeshan_Lalani/3
will redirect to example.com/team.php?name=Zeeshan_Lalani&id=3
The Rule I've tried to accomplish above url
RewriteRule ^team/([^/]+)/([0-9]+)\/?$ /team.php?name=$1&id=$2
But with this rule it have conflicts with page.php rule and renders 404 not found
error and when I comment the page.php rule it works fine.
Please suggest what am I doing wrong here?
Upvotes: 0
Views: 32
Reputation: 1722
You could try and use the [L] flag. The flag says that if the statement is correct, no other statements will be matched. Ex:
RewriteRule ^team/([^/]+)/([0-9]+)\/?$ /team.php?name=$1&id=$2 [L]
RewriteRule ^([^/]+)/([0-9]+)\/?$ /page.php?name=$1&id=$2 [L]
Be sure to have the "Team" rule above the other one, otherwise the second rule might match before the team rule can be applied.
Upvotes: 2