Forum Moderators: phranque
Im just getting the hang of this .htaccess thing and im wondering if there is a smarter way to write this code:
RewriteRule ^([a-zA-Z0-9_\-]+)/index.php?$ index.php?reg=$1
RewriteRule ^([a-zA-Z0-9_\-]+)/([a-zA-Z0-9_\-]+)/index.php?$ index.php?reg=$1&statename_=$2
RewriteRule ^([a-zA-Z0-9_\-]+)/([a-zA-Z0-9_\-]+)/([a-zA-Z0-9_\-]+)/index.php?$ index.php?reg=$1&statename_=$2&city_=$3
RewriteRule ^([a-zA-Z0-9_\-]+)/([a-zA-Z0-9_\-]+)/([a-zA-Z0-9_\-]+)/([a-zA-Z0-9_\-]+)/index.php?$ index.php?reg=$1&statename_=$2&city_=$3&hotelid=$4
RewriteRule ^([a-zA-Z0-9_\-]+)/([a-zA-Z0-9_\-]+)/([a-zA-Z0-9_\-]+)/([a-zA-Z0-9_\-]+)/([a-zA-Z0-9_\-]+)/index.php?$ index.php?reg=$1&statename_=$2&city_=$3&hotelid=$4&mod=$5 [L]
Use the [NC] flag to make pattern-matching case-insensitive. This allows you to use [A-Z] or [a-z] instead of [A-Za-z].
Use the [L] flag on every rule, unless you need to process the output of that rule through a subsequent rule.
Put your rules in order, from most-frequently-matched to least.
Jim