Search form parameter rewrite rule
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®ion=$2&title=$3 [L]
RewriteRule ^list/(.*)/(.*)/$ /List.php?category=$1®ion [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
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';
精彩评论