I'm trying to rewrite a dynamic URL using the following code:
RewriteRule (.*)/$ index.php?location=$1
RewriteRule (.*)/(.*)/$ index.php?location=$1&company=$2
I really need two rewrites as you can see from the above code. First, I need the page to rewrite just the location if that's all there is. For example, it would turn site.ccom/index.php?location=sandiego into site.com/sandiego/
This is working correctly.
However, when I try to add in the second variable it fails. It manages to detect the &company=1 variable, but for some reason it returns the ?location=sandiego variable as 'index.php'. For example, if I input the following: site.com/san-diego/1/ and then try to grab the $location and $company variables, it will only get the $company variable successfully, and the $location variable will be set to 'index.php', rather than 'san-diego'.
Any help would be greatly appreciated.