You are here:  » Shorter url (without product)


Shorter url (without product)

Submitted by marco@flapper on Fri, 2016-04-22 07:31 in

Hi,
I'm thinking about shortening the product url's. What will be needed to do that?

I found:
http://www.pricetapestry.com/node/5017

But what I want to do is to shorten the product url. For example it is now something like:
www.mydomain.com/product/productname.html

And I want it to be:
www.mydomain.com/productname.html

Is this possible or will this need a lot of modifications?

Submitted by support on Fri, 2016-04-22 07:53

Hi Marco,

No problem - to remove the /product/ component of the product page URLs, edit includes/tapestry.php and look for the following code at line 66:

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

...and REPLACE with:

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

And then in .htaccess, add the following at the very end of the file (catch all rules with no common component must go after all others)

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

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by marco@flapper on Fri, 2016-04-22 08:07

Thanks, this is easy.