Forum Moderators: phranque
[127.0.0.1...]
[127.0.0.1...]
[127.0.0.1...]
These all use this rule:
RewriteRule /([a-z-a-z]+)-([^.]+)\-bed-breakfast.html$ /accomm_scripts/accomm_city_srch.php?city=$2®ion=$1 [N]
Now when I use this url:
[127.0.0.1...] (the port-perry is lowwercase)
It doest seem to work.. The "ontario-toronto" is my region=$1 and the "port-perry" is my city=$2
The only difference when it doesnt work is that Port-Perry has a dash, as soon as I lowercase it it doesnt work.
RewriteRule /([a-z-a-z]+)-([^.]+)\-bed-breakfast.html$ /accomm_scripts/accomm_city_srch.php?city=$2®ion=$1 [N]
OK, so your pattern says, "accept one or more characters a to z lowercase or hyphen, followed by a dash and then one or more characters except a literal period, followed by "-bed-breakfast.html".
So how do these two URLs parse out using that pattern?
-----
URL /ontario-toronto-Port-perry-bed-breakfast.html:
$1 ontario-toronto
$2 Port-perry
"Port" won't match the pattern for $1 because it is uppercase.
-----
URL /ontario-toronto-port-perry-bed-breakfast.html
$1 ontario-toronto-port
$2 perry
"port" matches the pattern for $1 and so is included in $1.
-----
I suspect the problem is that your pattern ([a-z-a-z]+) does not do what you expect. That pattern is entirely equivalent to ([a-z-]+) -- The second "a-z" is redundant and does nothing. If you intend to require a hyphen between two groups of lowercase letters, then you'd need ([a-z]+-[a-z]+).
It all depends how you want to break down region and city, but your regular expressions appear to need some tweaking. Also, that [N] flag on the end means "Next" and will cause your mod_rewrite code to be "restarted" and re-processed until an exit condition is met. That's highly inefficient. If that is what you intended, I'd suggest finding a better way. If you intended to use [NC] to make the Rule case-insensitive, then this may explain some of the problem.
Based on my assumptions about what you're trying to do, I'd suggest:
RewriteRule /([a-z]+-[a-z]+)-(.+)\-bed-breakfast.html$ /accomm_scripts/accomm_city_srch.php?city=$2®ion=$1 [[b]NC[/b]]