You are here:  » Remove Category from URLs


Remove Category from URLs

Submitted by anthem on Mon, 2006-10-02 12:39 in

Hi,

Please could anyone tell me if it is possible to remove category: from URLs?

Using mod rewrite, I have managed to get it down to:-

http://www.url.com/search/q/category:red widgets:/

But would like to remove that "category:" if possible.

If anyone has any suggestions, I'd be very grateful.

Thanks in advance.

Submitted by support on Mon, 2006-10-02 12:54

Hi,

It is needed in the "q" parameter; however you could add it within your rewrite rule. For example; map

/search/cat/red widgets/

=>

/search.php?q=category:red widgets:

The rule would look something like this:

RewriteRule ^search/cat/(.*)/$ search.php?q=category:$1:&rewrite=1&%{QUERY_STRING} [L]

That should work...

Cheers,
David.

Submitted by atman on Mon, 2006-10-02 13:48

in relation to this.

i would like to know how to remove the

"Product search results for category:"

and the ":" on the example URL below

http://www.webpricecheck.co.uk/category/Access-Points/

leaving only the "Access Points" (w/out quotes) as the header

thank you

Submitted by support on Mon, 2006-10-02 13:58

Hi atman,

The header is set by line 95 of search.php:

    $banner["h2"] = translate("Product search results for")." <strong>".htmlentities($q,ENT_QUOTES,$config_charset)."</strong>&nbsp;";

If you only want to display the term and nothing else, try this:

    $banner["h2"] = htmlentities(($parts[1]?$parts[1]:$parts[0]),ENT_QUOTES,$config_charset)." ";

This works because the query is split up into the $parts array further up the script, so you can look at $parts[1] and if it contains anything use that, otherwise display $parts[0] (for a normal search).

Cheers,
David.

Submitted by atman on Tue, 2006-10-03 06:04

thanks david.