levorion Posted February 6, 2013 Share Posted February 6, 2013 Thank you for reading. I am trying to rewrite all dynamic category links (/product_list.php?cat_id=xxx) to more "friendly" text links. The problem I'm running into is with subcategories: RewriteRule Complete-AC-Systems product_list.php?cat_id=2 works great, however when a sub category is present: RewriteRule Complete-AC-Systems__Packaged-Systems product_list.php?cat_id=7 the browser stops reading after Complete-AC-Systems and re-directs to product_list.php?cat_id=2 not cat_id=7 Most of our categories are 3 and 4 levels in, so this is a pervasive issue. Thanks for any help you can offer. Quote Link to comment https://forums.phpfreaks.com/topic/274117-htaccess-rewrite-rules-stops-reading-url-after-first-part-of-string/ Share on other sites More sharing options...
levorion Posted February 6, 2013 Author Share Posted February 6, 2013 fixed by changing to order of the rules... longer ones first! Quote Link to comment https://forums.phpfreaks.com/topic/274117-htaccess-rewrite-rules-stops-reading-url-after-first-part-of-string/#findComment-1410524 Share on other sites More sharing options...
requinix Posted February 6, 2013 Share Posted February 6, 2013 Or you can be more explicit with the matching. RewriteRule ^Complete-AC-Systems$ product_list.php?cat_id=2 RewriteRule ^Complete-AC-Systems__Packaged-Systems$ product_list.php?cat_id=7 Also, this is horribly inefficient. Just modify your product_list.php so that it can look up the IDs given the names. Quote Link to comment https://forums.phpfreaks.com/topic/274117-htaccess-rewrite-rules-stops-reading-url-after-first-part-of-string/#findComment-1410560 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.