Support forum login

©2006-2012 IAAI Software

Contact Us Privacy Policy

change product to root with rewrite

Submitted by wilkins on Mon, 2010-03-01 15:09.

Hi David

Starting a new project and want to make the product page in root ie site.com/productname.html rather than site.com/product/productname.html, is this possible, htaccess seems easy but are there may changes to the script for this to work.

Thanks

Brent

Submitted by support on Mon, 2010-03-01 15:22.

Hello Brent,

It's generally straight forward - they key thing is to make sure that .htaccess takes into account any other actual files that may exist in your top level folder that might be confused with product URLs. RewriteCond can be used to get around this.

In your .htaccess, move the product/ rule from the beginning to the end of your .htaccess adjusting as required, and preceding it with the RewriteCond rules to prevent it from redirecting actual files or directories as follows:

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

With that in place, it's basically just a case of search and replacing:

product/

with nothing (leave the replace box empty) in the following files:

index.php
products.php
reviews.php
search.php
sitemap.php

Cheers,
David.

Submitted by Bigmac on Fri, 2011-04-08 08:18.

Hi David,

I am using PT in a subfolder as WP is in root and would like to remove product from the url so the products would be at domain.com/pt/abc.html instead of domain.com/pt/product/abc.html.

Is this possible? I am using 12/10A and have tried the above but I can't find any instance of product/ in index.php or products.php.

Many thanks.

Hamish

Submitted by support on Fri, 2011-04-08 08:23.

Hi Hamish,

Even easier in 12/10A as the product URL is generated by a function in includes/tapestry.php. After making the .htaccess changes as described above look for the following code at line 53:

return $config_baseHREF."product/".urlencode(tapestry_hyphenate($product["normalised_name"])).".html";

...and REPLACE that with:

return $config_baseHREF.urlencode(tapestry_hyphenate($product["normalised_name"])).".html";

Cheers,
David.
--
PriceTapestry.com

Submitted by Bigmac on Fri, 2011-04-08 08:38.

Thank you.

Tell me, is it as easy to force all urls to be lowercase?

Thanks again.

Cheers,

Hamish

Submitted by support on Fri, 2011-04-08 08:46.

Hi Hamish,

Sure - use the following as the replacement:

return $config_baseHREF.urlencode(tapestry_hyphenate(strtolower($product["normalised_name"]))).".html";

Cheers,
David.
--
PriceTapestry.com

Submitted by Bigmac on Fri, 2011-04-08 09:07.

Working nicely, thanks.

Am I right in saying I need to add (strtolower($product.....)) to categories.php, brands.php and merchants.php to make them lowercase, too?

Thanks again for your help.

Cheers,

Hamish

Submitted by support on Fri, 2011-04-08 10:00.

Hi Hamish,

Correct, in each of those files you'll find this line (or similar):

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

...REPLACE with:

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

Cheers,
David.
--
PriceTapestry.com

Submitted by Bigmac on Fri, 2011-04-08 10:07.

Do you not mean

urlencode(tapestry_hyphenate(strtolower($product["category"])))."/";

Just thinking of someone else.

Cheers,

H

Submitted by support on Fri, 2011-04-08 10:09.

Yes, sorry about that! Corrected above also...

Cheers,
David.
--
PriceTapestry.com