You are here:  » URL Rewriting for Multiple Filters

Support Forum



URL Rewriting for Multiple Filters

Submitted by Keeop on Tue, 2011-05-03 13:26 in

Hi David,

I'm wondering if you've got any ideas to help with the following.

I'm still looking at using the new search.php along with the filters to help with product searching on my sites. So basically, ending up with something like:

search.php?minPrice=10&maxPrice=600&categoryFilter=appliances&brandFilter=zanussi&newFilter1=builtin&newFilter2=white

The obvious beauty of using this method is that the query/links can be constructed in any order, so I can add extra filters easily and the user can 'build' them in any order. The only problem I have really, is with rewriting these urls. I've blocked dynamic content within robots.txt so need a rewritten version in order for the site to get spidered. I'm therefore thinking of just having the categories rewritten as this has worked best on other sites, so you have the standard:

/category/washing-machines/

The issue here is that to rewrite in this way, I need to have the &categoryfilter in a set position in the url in order to pick it up and rewrite it which then means I can no longer construct these queries in a random order any more.

Do you know of any way around this, either using PT or htaccess? I'm not too hot with htaccess so am unsure as to what may be possible.

Hope this makes sense?!

Cheers.
Keeop

Submitted by support on Tue, 2011-05-03 13:40

Hi Keeop,

My first thought is that do you really want to permit multiple URL paths to the same results? E.g

/appliances/zanussi/

...being equivalent to

/zanussi/appliances/

...as this would leave you with a lot of duplicate content URLs throughout your site.

That said, I can think of a method to allow an unordered structure, resulting in a query something along the lines of:

WHERE category IN ('zanussi','appliances') AND brand IN ('zanussi','appliances') etc..

This method requires the script parsing the whole rewritten URL and constructing field IN clauses for all fields that you're expecting. A tidier alternative would be something like

/category/appliances/brand/zanussi/

..or maybe:

/category/appliances/b/zanussi/

...which resolves to a far more straight forward RewriteRule, e.g.

RewriteRule ^category/(.*)/b/(.*)/(.*).html$ search.php?q=category:$1:&brandFilter=$2&page=$3&rewrite=1&%{QUERY_STRING} [L]
RewriteRule ^category/(.*)/b/(.*)/$ search.php?q=category:$1:&brandFilter=$2&rewrite=1&%{QUERY_STRING} [L]

(above must appear BEFORE the existing /category/ rules in .htaccess)

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by Keeop on Wed, 2011-05-04 09:46

Thanks David, will have a play!

Keeop