Reply
Multi-level category mod_rewriting
Old 08-26-2008, 08:28 PM Multi-level category mod_rewriting
Galaxian's Avatar
Dingleberry!

Posts: 664
Name: Rich
Location: United Kingdom
So, I am able to rewrite things, but only on one level.

For example: categories.php?name=test1 => categories/test1

However, how do I go about rewriting multiple levels of categories?

For example categories/specific_category/etc-category/test1.html
Galaxian is offline
Reply With Quote
View Public Profile Visit Galaxian's homepage!
 
When You Register, These Ads Go Away!
Old 08-27-2008, 04:09 AM Re: Multi-level category mod_rewriting
mtishetsky's Avatar
King Spam Talker

Posts: 1,134
Name: Mike
Location: Mataro, Spain
RewriteRule categories/([^/]+)?/?([^/]+)?/?(([^/]+\).html)? script.php?lvl2cat=$1&lvl3cat=$2&page=$4
__________________
Free Mobile Phone Themes

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 08-27-2008, 04:16 AM Re: Multi-level category mod_rewriting
Galaxian's Avatar
Dingleberry!

Posts: 664
Name: Rich
Location: United Kingdom
That's not what I mean.

What if you have a dynamic sub category system? You could have an unprecedented amount of sub categories and I'm sure declaring all those variables in the rewrite isn't the best way to go about it. Perhaps some sort of condition? I'm not up to scratch with this part of rewrite
Galaxian is offline
Reply With Quote
View Public Profile Visit Galaxian's homepage!
 
Old 08-28-2008, 05:58 AM Re: Multi-level category mod_rewriting
mtishetsky's Avatar
King Spam Talker

Posts: 1,134
Name: Mike
Location: Mataro, Spain
In this case you better handle all specific requests with single script and analyze the request in the script. In your example you may use something like
Code:
RewriteCond ^(categories.*) /categories.php?req=$1
and then
PHP Code:
$cats explode('/'$_GET['req']); 
__________________
Free Mobile Phone Themes

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 08-28-2008, 06:00 AM Re: Multi-level category mod_rewriting
mtishetsky's Avatar
King Spam Talker

Posts: 1,134
Name: Mike
Location: Mataro, Spain
In general, when you use mod_rewrite you should keep in mind that it is VERY resource greedy, so the more complex your rewrites are the more cpu it will take. In some conditions it is better to switch from mod_rewrite to request analysis in php.
__________________
Free Mobile Phone Themes

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Reply     « Reply to Multi-level category mod_rewriting
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.13240 seconds with 12 queries