You are here:  » Url translation or rewrite


Url translation or rewrite

Submitted by andben on Tue, 2016-12-20 15:49 in

Hi!

is it feasible to have better urls for non English language installations? for example changing the Url from "webpricecheck.co.uk/brand/ACER/" to "webpricecheck.co.uk/marca/ACER/" in case of Italian.

Also the same for category and merchant, I see that the translate.php file does not aply to Urls.

Thank you,
Andrea

Submitted by support on Tue, 2016-12-20 16:46

Hello Andrea,

Sure - this is very straight forward in the latest distribution as index links are generated through a single function - tapestry_indexHREF() in includes/tapestry.php beginning at line 301.

Specifically, look for the following code at lines 309, 313 and 317 respectively;

    $indexHREF["merchant"][TRUE] = "merchant/";

    $indexHREF["category"][TRUE] = "category/";

    $indexHREF["merchant"][TRUE] = "brand/";

Here, you can change the slugs you would like to use for your language, e.g. for brand URLs, to use "marca" you would change line 317 as follows;

    $indexHREF["brand"][TRUE] = "marca/";

With that in place, the corresponding changes just need to be applied in .htaccess, so continuing the /brand/ example, where you will have the following rules beginning at line 19:

RewriteRule ^brand/$ brands.php
RewriteRule ^brand/(.*)/$ search.php?q=brand:$1:&rewrite=1&%{QUERY_STRING} [B,L]
RewriteRule ^brand/(.*)/(.*).html$ search.php?q=brand:$1:&page=$2&rewrite=1&%{QUERY_STRING} [B,L]

...REPLACE with;

RewriteRule ^marca/$ brands.php
RewriteRule ^marca/(.*)/$ search.php?q=brand:$1:&rewrite=1&%{QUERY_STRING} [B,L]
RewriteRule ^marca/(.*)/(.*).html$ search.php?q=brand:$1:&page=$2&rewrite=1&%{QUERY_STRING} [B,L]

However, I know you have been using the script for several years now so if any of the above does not correlate with the distribution you are using, let me know and I'll post the changes required accordingly...

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by andben on Wed, 2016-12-21 02:54

Hi David, yes I am using the latest distribution, changed it

Thank you!
Andrea