The problem is I'm repeating my rules too often I think. Repeating code is never a good thing right, so I hope you can help me.
These are my current rewrite rules:
- Code: Select all
<IfModule mod_rewrite.c>
# Turn on the furnace.
RewriteEngine on
# Search for a brand
RewriteRule supplier/([a-z_0-9]+) index.php?var[]=search&b=$1 [NC]
# Search for a product (numbers only!)
RewriteRule product/([0-9]+) index.php?var[]=product&var[]=$1 [NC]
# 1-1-1/(abc-12)_(abc-12)_(abc-12)
RewriteRule ^([0-9]+)-([0-9]+)-([0-9]+)/([a-z0-9-]+)_([a-z0-9-]+)_([a-z0-9-]+) index.php?var[]=search&tree[]=$1&tree[]=$2&tree[]=$3&c=$4&s[]=$5&s[]=$6 [NC]
# 1-1/(abc-12)_(abc-12)_(abc-12)
RewriteRule ^([0-9]+)-([0-9]+)/([a-z0-9]+)_([a-z0-9-]+)_([a-z0-9-]+) index.php?var[]=search&tree[]=$1&tree[]=$2&c=$3&s[]=$4&s[]=$5 [NC]
# 1-1-1/(a_bc-12)
RewriteRule ^([0-9]+)-([0-9]+)-([0-9]+)/([a-z_0-9-]+) index.php?var[]=search&tree[]=$1&tree[]=$2&tree[]=$3&&c=$4 [NC]
# 1-1/(a_bc-12)
RewriteRule ^([0-9]+)-([0-9]+)/([a-z_0-9-]+) index.php?var[]=search&tree[]=$1&tree[]=$2&c=$3 [NC]
# 1/(a_bc-12)
RewriteRule ^([0-9]+)/([a-z_0-9-]+) index.php?var[]=search&tree[]=$1&c=$2 [NC]
</IfModule>
My links look like:
http://example.com/83/componenten.html <-- mainmenu
http://example.com/83-57/ram.html <-- submenu
http://example.com/83-57-61/ram_technol ... sdram.html <-- 3rd level (and so on)
My links for showing a product look like:
http://example.com/product/8189/ <-- product Id
Or, to keep the menu links 'open' when someone clicks a link in one of the overviews:
http://example.com/83-57-61/product/8189/
Or request all product by a supplier:
http://example.com/supplier/kingston.html
Basicly the menu can have an 'unlimited' amount of levels. This would cause me to have many of the same rewrite rules and might lead to an unmaintainable mess.
I'd appreciate any suggestions,
Vinc