Ben
Ben

Reputation: 62404

.htaccess problem not stopping after rule encountered

The 5th rule down on this page is triggered by the URL: /vehicles/Ford/Escape/2005/ BUT it gets rewritten by the 9th rule down and I can't figure out why. I've looked up htaccess flags and L should do the trick if I understand correctly which I already have on there.

#urls carried over from previous versions of the site
RewriteRule ^vehicles/([^/]+)/([^/]+)/([^/]+)/([0-9]+)$ /index.php?cmd=store&sec=product&act=view&id=$4&make=$1&model=$2&year=$3&%{QUERY_STRING} [L,NC]
RewriteRule ^vehicles/([^/]+)/([^/]+)/([^/]+)$ /index.php?cmd=store&sec=product&act=list&make=$1&model=$2&year=$3&%{QUERY_STRING} [L,NC]
RewriteRule ^vehicles/([^/]+)/([^/]+)$ /index.php?cmd=vehicle&sec=make&subsec=model&tiersec=year&act=list&make=$1&model=$2&%{QUERY_STRING} [L,NC]
RewriteRule ^vehicles/([^/]+)$ /index.php?cmd=vehicle&sec=make&subsec=model&act=list&make=$1&%{QUERY_STRING} [L,NC]
RewriteRule ^vehicles/$ /index.php?cmd=vehicle&sec=make&act=list&%{QUERY_STRING} [L,NC]

#lets not break the old vehicle search URL
RewriteRule ^vehicle_search/$ /vehicle/search/ [R=301]

#But fix the ones that need fixing (new standard format)
RewriteRule ^([^/]+?)/([^/]+?)/([^/]+?)/([^/]+?)/([^/]+?)/([^/]+?)/?$ /index.php?cmd=$1&sec=$2&subsec=$3&tiersec=$4&quadsec=$5&act=$6&%{QUERY_STRING} [L,NS]
RewriteRule ^([^/]+?)/([^/]+?)/([^/]+?)/([^/]+?)/([^/]+?)/?$ /index.php?cmd=$1&sec=$2&subsec=$3&tiersec=$4&act=$5&%{QUERY_STRING} [L,NS]
RewriteRule ^([^/]+?)/([^/]+?)/([^/]+?)/([^/]+?)/?$ /index.php?cmd=$1&sec=$2&subsec=$3&act=$4&%{QUERY_STRING} [L,NS]
RewriteRule ^([^/]+?)/([^/]+?)/([^/]+?)/?$ /index.php?cmd=$1&sec=$2&act=$3&%{QUERY_STRING} [L,NS]
RewriteRule ^([^/]+?)/([^/]+?)/?$ /index.php?cmd=$1&act=$2&%{QUERY_STRING} [L,NS]

Upvotes: 0

Views: 60

Answers (1)

Pekka
Pekka

Reputation: 449485

Nope, the fifth rule is not triggered by the URL you show. That rule is designed to catch vehicles/ only.

The 9th rule is indeed the first one that matches.

You'd have to extend the second rule to deal with slashes as well.

Upvotes: 1

Related Questions