Now, say I'm on the Spanish version of the site (http://domainname.com/es) and I click a product on the frontpage, I get redirected to the english version. How do I get this working?
I thought I could add extra "rules" to the .config-file, where I gave them other names and replaced ~/en/ with ~/es/ and ~/de/ - but that doesn't seem to work.
I don't believe it is a problem with the rewrite rules. You shouldn't have to tingle with them at all.
I'm guessing it is a problem with language, either in Umbraco or uCommerce.
On your frontpage you have some code to pull out your products. Could it be you get the wrong language version of the products there and therefore get the wrong link?
I think you are on the right track with the rewrite rules
The "right" way would be to "capture" the language part of the virtual url (like you do with the catalog,category and product id), and insert that one in the destinationurl.
The easy way would be to add a set of the 4 rules for each language.
Nickolaj poked me and my sickridden brain telling me I was wrong. I'm sorry I didn't catch it myself.
I would still like to help though with the redirects. I'm not 100% sure, where the virtualUrl start, if it catches the domain aswell or just the url. But I'm guessing it is just the url. You probably have to play a little with it. Anyway, my two cents.
I try to catch the language, which is set to 2 characters long right at the beginning of the url and then put it in the destination url at the beginning.
I'm not 100% sure it fits your needs completely, nor that it actually works, but I hope it helps.
More info about my setup: Each website has hostnames, fx.: website.com/en, website.com/es, website.com/cz
..with each their language selected.
The Splash Page node has a "umbracoInternalRedirectId" pointing to the /en site.
I also noticed that the products links to the same path (website.com/ucommerce/bla/bla/bla) - Shouldn't it be website.com/es/ucommerce when I'm on the spanish site, website.com/cz/ucommerce when i'm on the czech site?
Multilingual shop and rewriting urls
So I have this shop, where my node structure looks like this:
Content
-- Splash
---- Website (en)
---- Website (es)
---- Website (de)
In my /config/urlRewriting.config, I have the following :
<add name="DefaultCategoryProductRewrite" virtualUrl="(.*)/c-([0-9]+)/c-([0-9]+)/p-([0-9]+)" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/en/products/product.aspx?catalog=$2&category=$3&product=$4" ignoreCase="true" xmlns="" />
<add name="DefaultProductRewrite" virtualUrl="(.*)/c-([0-9]+)/p-([0-9]+)" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/en/products/product.aspx?catalog=$2&product=$3" ignoreCase="true" xmlns="" />
<add name="DefaultCategoryRewrite" virtualUrl="(.*)/c-([0-9]+)/c-([0-9]+)" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/en/products/catalog.aspx?catalog=$2&category=$3" ignoreCase="true" xmlns="" />
<add name="DefaultCatalogRewrite" virtualUrl="(.*)/c-([0-9]+)" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/en/products/catalog.aspx?catalog=$2" ignoreCase="true" xmlns="" />
On the homepage of the site, I have links to each product. When I click a product (on the english version of the page), I get to http://domainname.com/ucommerce/category/product/c-23/c-69/p-163/?sku=23106
Now, say I'm on the Spanish version of the site (http://domainname.com/es) and I click a product on the frontpage, I get redirected to the english version. How do I get this working?
I thought I could add extra "rules" to the .config-file, where I gave them other names and replaced ~/en/ with ~/es/ and ~/de/ - but that doesn't seem to work.
Could someone guide me in the right direction?
Br
Dan
Should I restructure my site, or is it possible to write more url rewriting rules?
I found this post: http://our.umbraco.org/projects/website-utilities/ucommerce/ucommerce-support/37239-Multilingual-content
The last comment from Søren; To me it sounds like I can add more rules?
I don't believe it is a problem with the rewrite rules. You shouldn't have to tingle with them at all.
I'm guessing it is a problem with language, either in Umbraco or uCommerce.
On your frontpage you have some code to pull out your products. Could it be you get the wrong language version of the products there and therefore get the wrong link?
Hi Dan
I think you are on the right track with the rewrite rules
The "right" way would be to "capture" the language part of the virtual url (like you do with the catalog,category and product id), and insert that one in the destinationurl.
The easy way would be to add a set of the 4 rules for each language.
Hi Dan.
Nickolaj poked me and my sickridden brain telling me I was wrong. I'm sorry I didn't catch it myself.
I would still like to help though with the redirects. I'm not 100% sure, where the virtualUrl start, if it catches the domain aswell or just the url. But I'm guessing it is just the url. You probably have to play a little with it. Anyway, my two cents.
<add name="DefaultCategoryProductRewrite" virtualUrl="^/(.+){2}/(.*)/c-([0-9]+)/c-([0-9]+)/p-([0-9]+)" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/$1/products/product.aspx?catalog=$3&category=$4&product=$5" ignoreCase="true" xmlns="" />
<add name="DefaultProductRewrite" virtualUrl="^/(.+){2}/(.*)/c-([0-9]+)/p-([0-9]+)" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/$1/products/product.aspx?catalog=$3&product=$4" ignoreCase="true" xmlns="" />
<add name="DefaultCategoryRewrite" virtualUrl="^/(.+){2}/(.*)/c-([0-9]+)/c-([0-9]+)" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/$1/products/catalog.aspx?catalog=$3&category=$4" ignoreCase="true" xmlns="" />
<add name="DefaultCatalogRewrite" virtualUrl="^/(.+){2}/(.*)/c-([0-9]+)" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/$1/products/catalog.aspx?catalog=$3" ignoreCase="true" xmlns="" />
I try to catch the language, which is set to 2 characters long right at the beginning of the url and then put it in the destination url at the beginning.
I'm not 100% sure it fits your needs completely, nor that it actually works, but I hope it helps.
Yo dudes! I'll try it out!... Hang on!
Hm... That gives me:
404 - File or directory not found.
:(
More info about my setup:
Each website has hostnames, fx.: website.com/en, website.com/es, website.com/cz
..with each their language selected.
The Splash Page node has a "umbracoInternalRedirectId" pointing to the /en site.
I also noticed that the products links to the same path (website.com/ucommerce/bla/bla/bla) - Shouldn't it be website.com/es/ucommerce when I'm on the spanish site, website.com/cz/ucommerce when i'm on the czech site?
Could you post how your urlRewriting.config looks?
I noticed in the links you wrote /ucommerce/ but in the rules you specify /products/
How is your content section put together?
Content
-Splash
--en
---? products or ucommerce?
----catalog
-----category
------product
--cz
---?
Content
-- Splash
---- Website (en)
------- products
---------- product
---- Website (es)
------- products
---------- product
---- Website (de)
------- products
---------- product
But maybe I need to have one step more?
Content
-- Splash
---- Website (en)
------- catalog
--------- products (category)
------------ product
---- Website (es)
------- catalog
--------- products (category)
------------ product
---- Website (de)
------- catalog
--------- products (category)
------------ product
I'll post the urlRewriting.config in about an hour (not at my work laptop atm.)
This is how my urlRewriting.config looks like atm:
<?xml version="1.0" encoding="utf-8"?>
<urlrewritingnet xmlns="http://www.urlrewriting.net/schemas/config/2006/07">
<rewrites>
<add name="DefaultCategoryProductRewrite" virtualUrl="(.*)/c-([0-9]+)/c-([0-9]+)/p-([0-9]+)" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/en/products/product.aspx?catalog=$2&category=$3&product=$4" ignoreCase="true" xmlns="" />
<add name="DefaultProductRewrite" virtualUrl="(.*)/c-([0-9]+)/p-([0-9]+)" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/en/products/product.aspx?catalog=$2&product=$3" ignoreCase="true" xmlns="" />
<add name="DefaultCategoryRewrite" virtualUrl="(.*)/c-([0-9]+)/c-([0-9]+)" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/en/products/catalog.aspx?catalog=$2&category=$3" ignoreCase="true" xmlns="" />
<add name="DefaultCatalogRewrite" virtualUrl="(.*)/c-([0-9]+)" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/en/products/catalog.aspx?catalog=$2" ignoreCase="true" xmlns="" />
</rewrites>
</urlrewritingnet>
I went back to the one that didn't give me a 404..
So should I do something with the urlRewriting and the actucal structure of my site in order to make it work?
Any other suggestions?
With a little (big) help from @greystate, I got it working:
<add
name="DefaultCategoryProductRewriteEN"
rewriteUrlParameter="ExcludeFromClientQueryString"
virtualUrl="~/en/(.*)/c-([0-9]+)/c-([0-9]+)/p-([0-9]+)"
destinationUrl="~/en/products/product.aspx?catalog=$2&category=$3&product=$4" ignoreCase="true"
/>
<add
name="DefaultCategoryProductRewriteES"
rewriteUrlParameter="ExcludeFromClientQueryString"
virtualUrl="~/es/(.*)/c-([0-9]+)/c-([0-9]+)/p-([0-9]+)"
destinationUrl="~/es/productos/product.aspx?catalog=$2&category=$3&product=$4" ignoreCase="true"
/>
is working on a reply...