change product to root with rewrite
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
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
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
Thank you.
Tell me, is it as easy to force all urls to be lowercase?
Thanks again.
Cheers,
Hamish
Hi Hamish,
Sure - use the following as the replacement:
return $config_baseHREF.urlencode(tapestry_hyphenate(strtolower($product["normalised_name"]))).".html";Cheers,
David.
--
PriceTapestry.com
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
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
Do you not mean
urlencode(tapestry_hyphenate(strtolower($product["category"])))."/";
Just thinking of someone else.
Cheers,
H
Yes, sorry about that! Corrected above also...
Cheers,
David.
--
PriceTapestry.com
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} !-fRewriteCond %{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.