Jump to content

mod_rewrite


unxposed

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/147717-mod_rewrite/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.