unxposed Posted March 3, 2009 Share Posted March 3, 2009 Okay new to mod_rewite. I need to turn a dynamic url with up to 7 variables, but could be as few as 1, into corresponding urls. I have got it working but with an insanely long winded way of doing things. Could anybody demostrate how I'd shorten this so I'd just use one RewriteRule. Many thanks!! RewriteRule ^manage/(dashboard|orders|products|users|settings|dashboard|content)/(all|new|income|categories|incomplete|discounts)/(view|edit|export|cancel|add|import|sort_by_id|sort_by_user|sort_by_total|sort_by_date|sort_by_status)/([0-9_]+)/([0-9_]+)/(add|edit|cancel)/(.*) manage/index.php?category=$1&sub_category=$2&action=$3&id=$4&product=$5&product_action=$6&additional=$7 RewriteRule ^manage/(dashboard|orders|products|users|settings|dashboard|content)/(all|new|income|categories|incomplete|discounts)/(view|edit|export|cancel|add|import|sort_by_id|sort_by_user|sort_by_total|sort_by_date|sort_by_status)/([0-9_]+)/([0-9_]+)/(add|edit|cancel) manage/index.php?category=$1&sub_category=$2&action=$3&id=$4&product=$5&product_action=$6 RewriteRule ^manage/(dashboard|orders|products|users|settings|dashboard|content)/(all|new|income|categories|incomplete|discounts)/(view|edit|export|cancel|add|import|sort_by_id|sort_by_user|sort_by_total|sort_by_date|sort_by_status)/([0-9_]+)/([0-9_]+) manage/index.php?category=$1&sub_category=$2&action=$3&id=$4&product=$5 RewriteRule ^manage/(dashboard|orders|products|users|settings|dashboard|content)/(all|new|income|categories|incomplete|discounts)/(view|edit|export|cancel|add|import|sort_by_id|sort_by_user|sort_by_total|sort_by_date|sort_by_status)/([0-9_]+) manage/index.php?category=$1&sub_category=$2&action=$3&id=$4 RewriteRule ^manage/(dashboard|orders|products|users|settings|dashboard|content)/(all|new|income|categories|incomplete|discounts)/(view|edit|export|cancel|add|import|sort_by_id|sort_by_user|sort_by_total|sort_by_date|sort_by_status) manage/index.php?category=$1&sub_category=$2&action=$3 RewriteRule ^manage/(dashboard|orders|products|users|settings|dashboard|content)/(all|new|income|categories|incomplete|discounts) manage/index.php?category=$1&sub_category=$2 RewriteRule ^manage/(dashboard|orders|products|users|settings|dashboard|content) manage/index.php?category=$1 Which is essentially just this (but made to accept either just 1 or upto 7 variables): RewriteRule ^manage/(dashboard|orders|products|users|settings|dashboard|content)/(all|new|income|categories|incomplete|discounts)/(view|edit|export|cancel|add|import|sort_by_id|sort_by_user|sort_by_total|sort_by_date|sort_by_status)/([0-9_]+)/([0-9_]+)/(add|edit|cancel)/(.*) manage/index.php?category=$1&sub_category=$2&action=$3&id=$4&product=$5&product_action=$6&additional=$7 Quote Link to comment 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.