Forum Moderators: phranque
RewriteEngine on
# Rewrite the area and name onto the search script to find the restaurant
RewriteRule ^([a-z-]+)/([a-z-]+)/$ restaurants.php?area=$1&name=$2 [NC,L]
However, I would now like to add a new directory structure (just by rewriting, no actual new directories) www.myurl.com/restaurants/food/(type of food)/
This would obviously conflict with my existing rule because it would search for an area of my city called "food". So I would like to construct a rule which checks if the URL starts /food/ and if so skip the first RerwiteRule and do the following:
RewriteRule ^/food/([a-z-]+)/$ /search/search.php?search_type=food&cuisine=$1 [NC,L]
As they currently stand, the two rules are contradictory (both match) and I cannot find out how to say "if the URL does NOT start with 'food' then follow the first rule, else follow the second rule".
I am guessing that a third rule may be needed to accomplish this but I can't think for the life of me how this would be constructed.
Any help appreciated! :)
** EDIT **
I just realised that all I need to do is place the second rule before the first and then it works perfectly. Sometimes it's the simplest things that you miss! ;)