I’m trying to do sorting passing get value in htaccess to php:
I have sth like:
RewriteRule ^pubs$ pubs.php
RewriteRule ^pubs/beer$ pubs.php?sort=beer
Above code is working fine. Now Im trying to do the same thing for subpages (cities):
RewriteRule ^pubs/(.*)$ district.php?name=$1
RewriteRule ^pubs/(.*)/beer$ district.php?name=$1&sort=beer
The links look like:
http://www.domain.com/pubs/beer – working ok
http://www.domain.com/pubs/new-york/beer – not working
What I’m doing wrong? If i delete line RewriteRule ^pubs/(.*)$ district.php?name=$1 then the link http://www.domain.com/pubs/new-york/beer is working. I spend hours to find solution with no luck. I will be grateful for help.
because http://www.domain.com/pubs/new-york/beer is matching by
resulting in district.php?name=newyork/beer instead of matching
one way you could fix this would be:
so if there is an additional slash anywhere after your city the rule will be ignored and proceed to the 2nd rule… just be sure to put it after
or it will match beer as if it were a city name like district.php?name=beer