views:

44

answers:

1

I am realy ,realy newbie in rewrite rules..
I have php script with a search form and with three imputs : title ; category ; region . User can search by title category or region , so the parameters can not be in a specific order.Sometime they search by title sometime only by category an region...

my rules

RewriteRule ^list/(.*)/(.*)/(.*)/$ /List.php?category=$1&region=$2&title=$3 [L]
RewriteRule ^list/(.*)/(.*)/$ /List.php?category=$1&region [L]
RewriteRule ^list/(.*)/$ /List.php?category=$1 [L] 
RewriteRule ^list/(.*)/(.*)/$ /List.php?region=$2&title=$3 [L]
RewriteRule ^list/(.*)/(.*)/$ /List.php?category=$12&title=$3 [L]

....and so on until I finish all permutation. Is there a way to control variables to get this :

/list/category/ /list/region/
/list/region/category/
/list/category/region/
/list/region/title/.....

? thanks in advance

A: 

why don't use

RewriteRule ^List\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /List.php [L]

so every request ist redireted to list.php

then explode it with

$folder = explode('/',substr($_SERVER['REQUEST_URI'],1));

for http://example.com/list/region/title you get

folder[0] = 'list';
folder[1] = 'region';
folder[2] = 'title';
revaxarts
Thank's but...what if a parameter from list is missing - How I know if folder[] is realy parameter let's say title - ex. title='title'.I think I am missing something, I don't know ...
morowind
I'll try to be more expicit :
morowind
I'll try to be more explicit : i nedd to now if i can have a rule for http://localhost/category-vehicle/subcategory-cars/brand-honda/region-london/ in this format (parameters name is category,subcategory,brand,region) - how can I parse this in PHP? and more important how to append qs if happening the user choose only region and brand ? simply I don't get it...
morowind