Forum Moderators: phranque
Welcome to WebmasterWorld!
It looks to me as if you are generating the static links inconsistently; Some have trailing slashes, and some don't. Similarly, some of the rewriterules you posted require a trailing slash, and some won't accept one.
That's the first place I'd look -- be consistent with the trailing slashes.
I'd also recommend adding an [L] flag to each rewriterule. This won't fix your problem, just make your site a bit faster, since it tells mod_rewrite to quit once a match is found and the URL is rewritten.
In the rewriterules, you can make the trailing slash optional be using the "/?$" construct at the end of each pattern. However, your link generation should still be consistent.
Jim
I would recommend changing it to:
# Return alphabetical pattern only (trailing/optional)
RewriteRule ^([a-z_-]+)/?$ /template.php?country=$1 [NC,L]
#Return alphabetical pattern/number/ (trailing/optional)
RewriteRule ^([a-z_-]+)/([0-9]+)/?$ /template.php?country=$1&page=$2 [NC,L]
#Return alphabetical pattern/alphabetical pattern/number/ (/number/ string optional)
RewriteRule ^([a-z_-]+)/([a-z_-]+)/?([0-9]+)?$ /template.php?country=$1&$2=$3 [NC,L]
NC designates No Case, should increase processing speed.
L designates last, quits processing all rules as soon as last is seen.
/template.php? needs to be the full path to the file EG if the template.php file is in the directory stuff the path needs to be changed to:
/stuff/template.php?
This should help you out.
Justin