You are here:  » URL structures


URL structures

Submitted by JasonG on Fri, 2013-05-10 14:35 in

Hi David

Is it possible to remove /category/ and /product/ from URL's - so we end up with dog-shop/James-Wellbeloved-Adult-Lamb-and-Rice-15Kg.html

instead of

dog-shop/product/James-Wellbeloved-Adult-Lamb-and-Rice-15Kg.html

Also does PT use any rel="canonical"

Thanks
STuart

Submitted by support on Fri, 2013-05-10 15:33

Hi Stuart,

To remove /product/, first it needs to be removed from where the product URL is generated, in includes/tapestry.php at line 53:

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

...and REPLACE with:

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

(but note that I just documented a mod to the same line regarding your other post about making the URLs all lower case - so the two need to be merged, let me know if you're not sure of course!)

With that done, it's just a case of updating .htaccess - look for the following rule at line 7:

RewriteRule ^product/(.*).html$ products.php?q=$1&rewrite=1&%{QUERY_STRING} [L]

...DELETE that line, and then insert at the end of .htaccess:

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

The RewriteCond lines are required to ensure that the rewritten product pages don't interfere with any other files on the site, and it must be the last rule in .htaccess in order to avoid conflicting with paginated merchant / category indexes etc. which also end in .html...

Cheers,
David.
--
PriceTapestry.com

Submitted by DVDAFFAIRES on Wed, 2014-06-11 12:14

Hello David.
I just made this change.
Products are displayed in root www.domain.com/johnn-smith.html.
But the navbar at the bottom, if you click on a number, can not find the products beyond page 1.
For example:
The merchants menu, click on a merchant.
All top 10 products are displayed and the search bar displays:
merchant: magma: -> OK
If you click a number in the navbar, we have products not found and the search bar displays:
mmagma2
The first character "m" indicates "merchant".
If I place ":" between the first character "m" and magma, it works.

Here is the URL if you want to understand directly:
{link saved}

Would you have any idea?

Best regards,
Raoul

Submitted by support on Wed, 2014-06-11 15:26

Hello Raoul,

I think you just need to move your new product rewrite rule to the end of .htaccess (the last rule) rather than the first, and this will let the merchant / category / brand navigation rewrites take priority - that should be all it is..

Cheers,
David.
--
PriceTapestry.com

Submitted by DVDAFFAIRES on Wed, 2014-06-11 17:16

Thank you David.
Everything works perfectly :)

Cheers,
Raoul

Submitted by wesse249 on Mon, 2016-10-03 08:03

Hello David,

I also removed the word /product/ from url. How can i redirect (with htaccess) old url's in Google http://www.example.com/product/test123.html to the new url http://www.example.com/test123.html

Thank you,

Jan Roel

Submitted by support on Mon, 2016-10-03 08:18

Hello Jan,

At the end of .htaccess, use:

RewriteRule ^product/(.*).html$ $1.html [L,R=301]

Cheers,
David.
--
PriceTapestry.com

Submitted by wesse249 on Mon, 2016-10-17 18:06

Hello David,

This solution isn't redirecting the productfolder to the root url. This is my htaccess:

{code saved}

Submitted by support on Tue, 2016-10-18 08:25

Hello Jan,

Your .htaccess still had the original product/ rewrite in place, at line 7:

RewriteRule ^product/(.*).html$ products.php?q=$1&rewrite=1&%{QUERY_STRING} [B,L]

...remove that line, and the new 301 redirect will then pick-up old product page URLs.

Cheers,
David.
--
PriceTapestry.com

Submitted by wesse249 on Tue, 2016-10-18 09:36

Hello David,

Sorry yes i allready removed that line. Without that line it is also not working.

Example: {link saved}

Thank you.

JR

Submitted by support on Tue, 2016-10-18 10:47

Hello Jan,

Ah - I see what it is - the "catch all" rule to redirect the top level product page URLs needs to be the very last rule in .htaccess - so all you need to do is move the new redirect rule:

RewriteRule ^product/(.*).html$ $1.html [L,R=301]

...back up to where the original /product/ rewrite rule was, immediately after the RewriteBase line...

Cheers,
David.
--
PriceTapestry.com

Submitted by wesse249 on Tue, 2016-10-18 11:08

Thankt it works now!

Submitted by wesse249 on Fri, 2017-03-17 20:05

Hello David,

I have this code on my website:

RewriteRule ^product/(.*).html$ $1.html [L,R=301]

How can i turn above code from:

http://example.com/product.html to http://example.com/product/product.html also with 301?

Thanks Jan Roel

Submitted by support on Sat, 2017-03-18 08:01

Hello Jan,

To go the other way round, you would use:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*).html$ product/$1.html [L,R=301]

- make sure the original RewriteRule for /product/ is back in place (copy from htaccess.txt in the distribution if you're not sure) and importantly in this case, the above rules must go _last_ in .htaccess, otherwise it would pick-up the pagination links e.g. /2.html etc...

Cheers,
David.
--
PriceTapestry.com