You are here:  » Remove Category from URLs

Support Forum



Remove Category from URLs

Submitted by mally on Sun, 2009-09-13 11:36 in

Hello David

Could you go through whats needed to Remove Category from URLs please?

Thanks Mally

Submitted by support on Mon, 2009-09-14 13:37

Hi Mally,

First stage is to add the the new rule to .htaccess; enclose within a "not exists" check to ensure that the rule doesn't conflict with other files or directories on your site. This is easy to do - in your .htaccess add the following at the very end:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ search.php?q=category:$1:&rewrite=1%{QUERY_STRING} [L]
RewriteRule ^(.*)/(.*).html$ search.php?q=category:$1:&page=$2&rewrite=1%{QUERY_STRING} [L]

Next, wherever links to categories are created or hardcoded, the /category/ section can be removed. Within the category index, categories.php, this would be a case of changing line 20 from:

          $item["href"] = tapestry_hyphenate($product["category"])."/";

to:

          $item["href"] = $config_baseHREF.tapestry_hyphenate($product["category"])."/";

(using $config_baseHREF has the effect of removing /category/ from the URL)

Line 41 of your sidebar script (re: your recent email) would need to be changed from

$href = $config_baseHREF."category/".tapestry_hyphenate($row["category"])."/";

to:

$href = $config_baseHREF.tapestry_hyphenate($row["category"])."/";

Hope this helps!

Cheers,
David.